Hi kvarnerexpress,
I've same problem with you, and after googling for days i didnt found what i want. but the basic for upload file is by sending "Content-Type: multipart/form-data" header. I used INET(Mic. Internet Transfer Control SP4) control for this. I've named this control INETPOST.
assuming the field name is "myfile" and the button name is "upload" for the upload form
CODE
' create sub for making upload post
private sub upload_file()
dim strPOST as string, Header as string Boundary as string, uagent as string
dim Idboundary as string ' id boundary for the site, it may different
uagent = "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7"
INETPOST.host = "www.somesite.com"
Idboundary = "9876543210123" ' you can generate this number
Boundary = String(27, "-") & Idboundary ' mutipart post need "-" sign
Header = uagent & vbCrLf & "Content-Type: multipart/form-data; " & "boundary=" & Boundary
strPOST = "--" & Boundary & vbCrLf & _
"Content-Disposition: form-data; name=""myfile""" & vbCrLf & vbCrLf & _
""" & EncodeBin & """ & vbCrLf & _
"--" & Boundary & vbCrLf & _
"Content-Disposition: form-data; name=""upload""" & vbCrLf & vbCrLf & _
"Upload File" & vbCrLf & _
"--" & Boundary & "--" & vbCrLf
INETPOST.Execute "http://www.somesite.com/upload.php", "POST", strPOST, Header
' Wait untill it finished
Do Until BekasNET.StillExecuting = False: DoEvents: Loop
end sub
' function to encode binary file
Function EncodeBin(SourceFile As String)
Dim buf As String, File1 As Integer
File1 = FreeFile
Open SourceFile For Binary Access Read As #File1
' make buffer to storing file's content
buf = Space(LOF(File1))
Get #File1, , buf
Close #File1
EncodeBin = buf
End Function
Hope's help!!

Reply