Trying to use this vb6 program to upload a file to a server, and ther server is giving me this error.
"Not supported Content-Disposition"
Here is the code
Code:Option Explicit 'This code uploads a file to an ASP script using http post 'You need to add a reference to Microsoft XML 3.0 to the project. 'Get this from http://msdn.microsoft.com/xml Private Sub cmdSubmit_Click() Dim strText As String Dim strImage As String Dim s$ Dim strBody As String Dim aPostData() As Byte Dim strFileName1 As String 'Dim strFileName2 As String Dim oHttp As XMLHTTP Dim nFile As Integer 'make use of the XMLHTTPRequest object contained in msxml.dll Set oHttp = New XMLHTTP 'read the whole text file strFileName1 = InputBox("Text File Name:", "Upload a file", "C:\Documents and Settings\rthomas\Desktop\upload.txt") nFile = FreeFile Open strFileName1 For Binary As #nFile strText = String(LOF(nFile), " ") Get #nFile, , strText Close #nFile 'read a GIF file 'strFileName2 = InputBox("Image File Name:", "Upload a file", "c:\temp\test.gif") 'nFile = FreeFile 'Open strFileName2 For Binary As #nFile 'strImage = String(LOF(nFile), " ") 'Get #nFile, , strImage 'Close #nFile 'fire of an http request 'adapt path in next line oHttp.Open "POST", "http://****************", False oHttp.setRequestHeader "Content-Type", "multipart/form-data, boundary=AaB03x" 'assemble the body. send one field and two files strBody = _ "--AaB03x" & vbCrLf & _ "Content-Disposition: form-data; name=""field1""" & vbCrLf & vbCrLf & _ "test field" & vbCrLf & _ "--AaB03x" & vbCrLf & _ "Content-Disposition: attachment; name=""FILE1""; filename=""" & strFileName1 & """" & vbCrLf & _ "Content-Type: text/plain" & vbCrLf & vbCrLf & _ strText & vbCrLf & _ "--AaB03x--" 'must convert to byte array because of binary zeros aPostData = StrConv(strBody, vbFromUnicode) 'send it oHttp.send aPostData 'check the feedback Debug.Print oHttp.responseText End Sub
Why do you think I'm getting this error? THanks in advanced.


Reply With Quote