Jump to content

Upload binary data WinHTTP


 Share

Recommended Posts

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]

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 1 year later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...