Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

WINHTTP UPLOAD WORD DOC



  • Please log in to reply
4 replies to this topic
tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
So i can do it just fine with this
<!-- m -->http://www.motobit.c...pg_uploadvbsie/<!-- m -->
However i really want to keep this AHK

The problem is (i really am ashamed of myself) is that i dont seem to understand how to build the exact same header file WITH binary data using AHK

Actually binary seems not the problem but the binary 0's.
the file uploads but is full of null characters instead

So how can i build this post data using AHK
word DOC
Example Post Data

I dont really care where it uploads to and i have been trying in vein to use [VxE]'s http function which works fine for anything without binary 0's.

I am convinced its just in building and sending a proper binary postdata that is the problem since a vbs equivalent works

Any insight. I assume the answer lies in strput but its all above my tiny little mind any help would be grand

VxE
  • Moderators
  • 3622 posts
  • Last active: Dec 24 2015 02:21 AM
  • Joined: 07 Oct 2006
✓  Best Answer
I'm sorry HTTPRequest() isn't working in your case, mixing text and binary data (multipart/form-data) is tricky in the best cases. Nimda had a similar issue.

You could try saving the POST data to a file (using a combination of normal/binary file writes), then using the POST-from-file option of HTTPRequest:
HTTPRequest( url, response := "", headers, "Upload: " PathToFile )


tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
Thanks I will test this idea this evening late but wanted to let you know I am thankful for the advise. I almost tried something similar but got kinda discouraged and failed to test that idea. In fact i hadnt thought about prepending the boundry+multipart to this so if i had tried this idea i would have failed miserably

Thanks you for your awesome support of your thread. If it works i will post my completed solution in your thread if thats fine with you?
Never lose.
WIN or LEARN.

VxE
  • Moderators
  • 3622 posts
  • Last active: Dec 24 2015 02:21 AM
  • Joined: 07 Oct 2006
YW. Every experience with multipart/form-data in AHK, whether successful or not, is potentially valuable for other users, so feel free to post your results in the HTTPRequest thread.

Also, providing support for multipart/form-data is something I've been mulling over. My gut tells me not to tweak the main HTTPRequest function, so I may develop a function for assembling the data and include it with the main function.

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
Great news i finally got time to test and your idea works perfectly I will post a really bad example later this evening
Never lose.
WIN or LEARN.