Hi all,
I'm trying to setup an ASP page to POST an image across to another page- essentially simulating what a browser does when you use <input type=file> in a HTML form.
I'm able to correctly setup the headers etc and do the POST, but I'm unable to include the binary data of the image. The only way i've been able to do it is if I base64 encode the image. I'm using MSXML2.ServerXMLHTTP to do the POST, and I can't seem to do the .send with a form body that includes the binary data of the image.
So, here's the form body i'm sending:
And here's what I want to send (this is what a browser sends when you use a form and browse to the same file):
And here's some of the code used:
I can read the binary data from the image using ADODB.Stream, but I can't seem to make a formData variable that will have that AND the plain text parts of the form. Anyone able to help?
Posting code? Wrap it with code tags: [ignore]
[ignore][/code][/ignore].
I'm trying to setup an ASP page to POST an image across to another page- essentially simulating what a browser does when you use <input type=file> in a HTML form.
I'm able to correctly setup the headers etc and do the POST, but I'm unable to include the binary data of the image. The only way i've been able to do it is if I base64 encode the image. I'm using MSXML2.ServerXMLHTTP to do the POST, and I can't seem to do the .send with a form body that includes the binary data of the image.
So, here's the form body i'm sending:
Code:
---------------------491299511942
Content-Disposition: form-data; name="fileupload"; filename="small.gif"
Content-Type: image/gif
Content-Transfer-Encoding: base64
R0lGODlhCgAKAIAAAP8AAAAAACH5BAAAAAAALAAAAAAKAAoAAAIIhI+py+0PYysAOw==
---------------------491299511942--
Code:
-----------------------------304891371731000
Content-Disposition: form-data; name="fileupload"; filename="small.gif"
Content-Type: image/gif
GIF89a
€ ÿ !ù ,
„?©Ëíc+ ;
-----------------------------304891371731000
And here's some of the code used:
Code:
DIM xmlhttp
SET xmlhttp = SERVER.CREATEOBJECT("MSXML2.ServerXMLHTTP")
xmlhttp.OPEN "POST", URL, FALSE
xmlhttp.setRequestHeader "Content-Type", "multipart/form-data; boundary=" & boundary
xmlhttp.setRequestHeader "Content-Length", len(filecontents)
xmlhttp.send formData
return = xmlhttp.responsetext
SET xmlhttp = NOTHING
I can read the binary data from the image using ADODB.Stream, but I can't seem to make a formData variable that will have that AND the plain text parts of the form. Anyone able to help?
Posting code? Wrap it with code tags: [ignore]
Code:
[/ignore][code]CodeHere