I'm using VB.NET 2005, Framework 2.0 to develop a Windows Application and not web application
I need to upload a zip file from local PC to a desired URL with the following syntax
http://localhost:xxxx/tsc/WOSync.do?action=upload&mkey=xxxx&wo[0]=<file>
How can I do it? The syntax is from a vendor who developed the web app in java.
This piece of code is in vb6 works, how to convert to vb.net
'Create an instance of the WinHttpRequest object
Set WinHttpReq = New WinHttpRequest
'Hard coded URL that HTTP Request will be performed
'strURL = "http://localhost/retail/eod.do?action=submit"
'Set the zip file's path name
StrFileName = App.Path & "\ddmmmyyy.zip"
'Grap the file
nFile = FreeFile
Open StrFileName For Binary As #nFile
strFile = String(LOF(nFile), " ")
Get #nFile, , strFile
Close #nFile
'Assemble an HTTP request.
WinHttpReq.Open "POST", strURL, False
'Set the header
WinHttpReq.setRequestHeader "Content-Type", "multipart/form-data; boundary=Xu02=$"
'Assemble the body
strBody = "--Xu02=$" & vbCrLf & _
"Content-Disposition: form-data; name=""file""; filename=""" & StrFileName & """" & vbCrLf & _
"Content-type: file" & vbCrLf & vbCrLf & _
strFile & vbCrLf & _
"--Xu02=$--"
'Because of binary zeros, post body has to convert to byte array
aPostBody = StrConv(strBody, vbFromUnicode)
'Send the HTTP Request.
WinHttpReq.send aPostBody
Hi,
If your using .net why dont you use the WebClient class?. The WebClient.UploadFile() Method should help you. Refer to documentation in MSDN
http://msdn.microsoft.com/en-us/library/36s52zhs.aspx
Surender.