Wednesday, 23 April 2014

How to post a file on a web form using wget


The command
wget --header="Content-type: multipart/form-data boundary=FILEUPLOAD" --post-file postfile http://domain/uploadform
Content of postfile below

--FILEUPLOAD
Content-Disposition: form-data; name="comment"

I love uploading files!

--FILEUPLOAD
Content-Disposition: form-data; name="userfile"; filename="yourfile.bin";
Content-Type: application/octet-stream
Media Type: application/octet-stream

content_of_you_file_comes_here

--FILEUPLOAD--

That's it!

[source]