Jump to content
Alex87

Send *.png by multipart request

Recommended Posts

Hi everyone! Good luck and have a nice day...

i have some trouble with one task.... i need to send *.png file 

I tryed it by this one :

$binary = FileRead('1.png')
;$boundary = "-----" & Random(10000000, 99999999, 1)

$postpacket =  $boundary & @CRLF & _
               'Content-Disposition: form-data; name="file"; filename="1.png"' & @CRLF & _
               'Content-Type: image/png' & @CRLF & @CRLF & _
               $binary & @CRLF & _
               $boundary & '--' & @CRLF

$SendData = StringToBinary($postpacket,1)

Local $oRequest = ObjCreate('WinHttp.WinHttpRequest.5.1')
$oRequest.Open('POST', 'https://site.com/in.php?key=123456', 0)
$oRequest.SetRequestHeader('Content-Type', 'multipart/form-data; boundary=')
$oRequest.SetRequestHeader('Content-Length', BinaryLen($binary))
$oRequest.Send($SendData)
Local $sResp = $oRequest.ResponseText
MsgBox(16,'$sResp',$sResp)

But i really dont know how to connect correctly my *.png file ....

I always get answer from server : "No file" or "Zero file size".

Have any idea?

 

Share this post


Link to post
Share on other sites

First of all, welcome to the forum :welcome: !

You only need to type some search terms in Google to receive suggestions, e.g. :

<Autoit Send *.jpg multipart request>  or  <Autoit Send image multipart request>

The WinHttp-UDF from @trancexx is also very helpful, see e.g. : upload-file-by-winhttp


Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...