Solved

Send data to asp page

Posted on 2004-10-05
4
170 Views
Last Modified: 2010-05-02
i am using this function

Private Sub upload(filename As String)

    On Error GoTo ErrHandler

    Dim aPostData() As Byte
    Dim vPostData As Variant
    Dim vUrl As Variant
    Dim vHeaders As Variant
    Dim strText As String
    Dim strContentHeader As String
    Dim strBody As String
    Dim nFile As Integer

    strContentHeader = "Content-Type: text/plain" & vbCrLf
    'read the whole file
    nFile = FreeFile
    Open filename For Binary As #nFile
    strText = String(LOF(nFile), " ")
    Get #nFile, , strText
    Close #nFile
    'http header
    vHeaders = "Content-Type: multipart/form-data, boundary=AaB03x" & vbCrLf
    'assemble the body. send one field and one file
    strBody = ""
   
    strBody = strBody & "--AaB03x" & vbCrLf
    strBody = strBody & "Content-Disposition: attachment; name=""FILE1""; filename=""" & filename & """" & vbCrLf
    strBody = strBody & strContentHeader & vbCrLf
    strBody = strBody & strText & vbCrLf
    strBody = strBody & "--AaB03x--"
    'must convert to byte array
    aPostData = StrConv(strBody, vbFromUnicode)
    vPostData = aPostData
    'post to...
    vUrl = "http://........................asp"
    'Do it!
    WebBrowser1.Navigate vUrl, 0, "", vPostData, vHeaders
    Exit Sub
ErrHandler:
    Err.Clear
    upload filename
    Close #nFile
    Exit Sub
End Sub


it works just like it i had a form like the following

<FORM name="send" method="post" encType="multipart/form-data" action="http://....asp">
      <INPUT type="File" name="File1" size="20">
      <INPUT type="Submit" value="Upload">
</FORM>


it works fine

but i want to add a field to it

like the form

<FORM name="send" method="post" encType="multipart/form-data" action="http://....asp">
      <INPUT type="hidden" name="firstname" value="gerald">
                 <INPUT type="File" name="File1" size="20">
      <INPUT type="Submit" value="Upload">
</FORM>

thanks in advance
0
Comment
Question by:gezzuzz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 17

Accepted Solution

by:
zzzzzooc earned 230 total points
ID: 12233012
The format will go something such as the below...

(START)
-----------------------------7d428027f101d8
Content-Disposition: form-data; name="File1"; filename="c:\myfile.txt"
Content-Type: text/plain

myfile.txt's data
-----------------------------7d428027f101d8
Content-Disposition: form-data; name="firstname"

gerald
-----------------------------7d428027f101d8--
(END)


This is not a regular method for form values being submitted so the ASP script will have to parse for both the file-data and the input values.
0
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 12537833
ping
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
using Access 8 83
Search combo error "Data Type Mismatch in Criteria Expression" 2 81
Zip Folders Using Chilkat Routines 1 71
transition to visual .net from vb6 5 59
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question