Solved

Send data to asp page

Posted on 2004-10-05
4
168 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
  • 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel VBA combine two working workbooks 8 54
Sending a email via excel using vba 6 82
Adding to a VBA? 6 70
VBA: copy range dynamically based on config sheet v2 3 34
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

777 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