HttpRequest Post image

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
rblack
Pro Scripter
Posts: 87
Joined: Sat Dec 22, 2007 12:39 pm

HttpRequest Post image

Post by rblack » Sun Feb 24, 2008 10:51 pm

hello again,
i wasnt posting for a long time, because macro sheduller works great without any bugs :)
I'm posting because i searched the forums, and found no answer to the following issue:

How to send an image via http post?

In the page where i upload the image there is the following instruction:
You must POST with "Content-Type: multipart/form-data".
parameter:
file - send the graph image (.jpg)
How to implement that with macro sheduller? I have webrecorder but there is nothing in documentation. I tried with many ways (also with some VBSCRIPTS on this forum) but nothing works and now i am out of ideas.
Could you help me please?

Lets say that the script where i upload the image is http://photo.com/upload.php so it will be easier to understand ;)

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Feb 25, 2008 8:58 am

This is something that the web browser usually handles. The file is binary data which is sent by the browser. The data would have to be encoded and the appropriate headers sent. I'm not sure that this would be easily replicated with the HTTPRequest command.

Here's the spec for form based file uploads:
http://www.ietf.org/rfc/rfc1867.txt

I did a bit of googling and found this VBScript method that uses IE to transparently post file form data:

http://www.motobit.com/tips/detpg_uploadvbsie/

Maybe you could use that in a VBSTART/VBEND block and customise as necessary.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

rblack
Pro Scripter
Posts: 87
Joined: Sat Dec 22, 2007 12:39 pm

Post by rblack » Mon Feb 25, 2008 10:53 am

Yes, i can handle it with webbrowser, but using httprequest directly is faster.

Well all i needed to use this via macro scheduller is just to change the content type from asci text to:

"Content-Type: multipart/form-data"

But how to do that in the macrosheduler standard httprequest command?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Feb 25, 2008 10:56 am

Yes, i can handle it with webbrowser, but using httprequest directly is faster.
The example posted above uses IE programmatically in hidden mode. Doubt it would be as slow as you think.
Well all i needed to use this via macro scheduller is just to change the content type from asci text to:

"Content-Type: multipart/form-data"
You can't. And you'd also need to be able to read in binary data and encode it.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts