• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 175
  • Last Modified:

Send data to asp page

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
gezzuzz
Asked:
gezzuzz
  • 2
1 Solution
 
zzzzzoocCommented:
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
 
zzzzzoocCommented:
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!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now