Jump to content
Sign in to follow this  

Multipart file uploading using winhttp.winhttprequest.5.1

Recommended Posts


i'm trying to upload some image files to server using post method.

i got NullPointerException error from server that is implemented on spring framework.

the server didn't receive the capturedImageFile field.

please let me know what problem and solution are.
here is my piece of code

Local $boundary = "------" & _TimeToTicks(@HOUR, @MIN, @SEC)
Local $contentDisposition = "form-data; name=""capturedImageFile""; filename=""" & $sFileName & '"'
Local $contentType = "multipart/form-data"
Local $origin = "null"

$http = ObjCreate("winhttp.winhttprequest.5.1")
$http.Open("POST", $sUrl, False)
$http.SetRequestHeader("Content-Type", $contentType & "; boundary=" & $boundary)

Local $hFile = FileOpen($sFileName, 16)
Local $postData = $boundary & @LF
$postData &= 'Content-Disposition: form-data; name="capturedImageFile"; filename="' & $sFileName & '"' & @LF
$postData &= "Content-Type: " & "image/bmp;" & @LF
$postData &= @LF & FileRead($hFile) & @LF
$postData &=  $boundary & "--"

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.