I am trying to POST a binary file to a web form
I am using the following routine to do the POST:
right at the inet.Execute command, it dies with the following error:
Run-time error '35760'
Cannot coerce type
Please help!
Code:
<FORM ENCTYPE="multipart/form-data" method="POST" action="act_upfile">
<INPUT TYPE=FILE NAME="filename">
<INPUT TYPE=SUBMIT NAME="Upload">
</FORM>
I am using the following routine to do the POST:
Code:
Private Sub cmdUpload_Click()
Dim TempArray() As Byte
Dim Encoded() As Byte
Dim Message As String
If FileExists(txtFile.text) = False Then
MsgBox "The file you have selected does not exist"
End If
cmdUpload.Enabled = False
cmdBrowse.Enabled = False
txtFile.Enabled = False
lblStatus.Caption = "Uploading file..."
strHead = "Content-Type: multipart/form-data; boundary=913114112" & vbCrLf
LoadFile txtFile.text, pbBuffer1
ByteArrayToString pbBuffer1, ptContent
Base64.Str2ByteArray ptContent, TempArray
Base64.EncodeB64 TempArray, Encoded
Base64.Span 74, Encoded, TempArray
ByteArrayToString TempArray, ptContent
strFormData = "-----------------------------913114112" & vbNewLine
strFormData = strFormData & "Content-Disposition: form-data; name=""Bcmd""" & vbNewLine & vbNewLine & "0" & vbNewLine
strFormData = strFormData & "-----------------------------913114112" & vbNewLine
strFormData = strFormData & "Content-Disposition: form-data; name=""SUBMIT""" & vbNewLine & vbNewLine
strFormData = strFormData & "Upload" & vbNewLine
strFormData = strFormData & "-----------------------------913114112" & vbNewLine
strFormData = strFormData & "Content-Disposition: form-data; "
strFormData = strFormData & "name=""filename""; filename=""" & txtFile.text & """" & vbNewLine
strFormData = strFormData & "Content-Transfer-Encoding: BASE64" & vbNewLine
strFormData = strFormData & "Content-Type: multipart/form-data" & vbNewLine & vbNewLine & ptContent & vbNewLine
strFormData = strFormData & "-----------------------------913114112--"
strLen = Len(strFormData)
MsgBox strFormData
Inet.Execute txtIP.text & ":" & txtPort.text & "/act_upfile", "POST", strFormData, strHead
While Inet.StillExecuting
DoEvents
Wend
MsgBox "The file was successfully uploaded", vbInformation, "File Uploaded"
cmdUpload.Enabled = True
cmdBrowse.Enabled = True
txtFile.Enabled = True
End Sub
right at the inet.Execute command, it dies with the following error:
Run-time error '35760'
Cannot coerce type
Please help!