Sign in to follow this  
Followers 0
MATISZON

Upload binary data WinHTTP

5 posts in this topic

#1 ·  Posted (edited)

Hello. I have a problem trying to send binary data (image) using WinHTTP.

My script:

$f = FileOpen("avek.gif")
$dataf = FileRead($f)
FileClose($f)


$data = 'Content-Disposition: form-data; name="userfile"; filename="avek.gif"' & @CRLF
$data &= 'Content-Type: image/gif' & @CRLF & @CRLF
$data &= $dataf


$http = ObjCreate("winhttp.winhttprequest.5.1")
$http.Open("POST", "http://zapodaj.net/upload.html")
$http.SetRequestHeader("Connection", "keep-alive")
$http.SetRequestHeader("Content-Type", "multipart/form-data")
$http.Send($data)
MsgBox(0,0,$data)
FileDelete("del.html")
FileWrite("del.html", $http.ResponseBody)

Screen from LiveHTTPHeader

Posted Image

Please, Help me :]

Edited by MATISZON

[size="3"][font="Arial Black"]I'm from the Polish do not as well know how English[/font][/size]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You can use WinHttp.au3 for that:

#include "WinHttp.au3"

; Initialize and get session handle
Global $hOpen = _WinHttpOpen()
; Get connection handle
Global $hConnect = _WinHttpConnect($hOpen, "zapodaj.net")
Global $sHTM = _WinHttpSimpleFormFill($hConnect, Default, "index:0", "name:userfile", @ScriptDir & "\avek.gif")
; Close handles
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)

ConsoleWrite(">Server response:" & @CRLF & $sHTM & @CRLF)
Edited by trancexx

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Your code is working.

Can someone show me working code with com object?


[size="3"][font="Arial Black"]I'm from the Polish do not as well know how English[/font][/size]

Share this post


Link to post
Share on other sites

@refresh


[size="3"][font="Arial Black"]I'm from the Polish do not as well know how English[/font][/size]

Share this post


Link to post
Share on other sites

Your code is working.

Can someone show me working code with com object?

Would like that too :)

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  
Followers 0