This question was repeatedly asked by other people in one form or another, but most remained unanswered, or this answer was "Use C #, duh!", Which, incidentally, is not the answer .; -)
I want to upload a zip file to a web server via VBA. Server-side code already exists and works well; it accepts zip files by manually loading the form and does something with the contents of the zip file.
In theory, I plan to convert the binary contents of the zip file to an HTTP request string and send it to the server using some methods from the WinHTTP library. If all goes well, the server side of the script (in Perl) will not be able to determine if the file came from VBA or the browser and continued to work normally.
However, transforming the zip file into an HTTP request string does not seem very straightforward.
A search on the Internet seems to indicate 3 common strategies:
Method 1: WinHTTP and Manually Encoding a Binary Request String to HTTP
- It involves opening a file in binary mode and manually applies some voodoo encoding to change the binary stream to the HTTP request string and sends it along the way using WinHTTP. Scary code.
Method 2: WinHTTP
- Enables the use of ADODB.Stream. Less than ten lines of code.
Method 3. Automate IE via SendKeys
- There is only one word to describe this hack: Yuck! And will probably break in a future version of IE if not. Less than ten lines of code. Safety.
2, , , , . , , . ?
1 .
3 , ! ( #, . Love #, VBA)
- , ?