Boris Guéry
Boris Guéry

Reputation: 47585

How to use the POST command to send a file?

I would like to send a file using the POST command available on almost all linuxes which include Perl.

I'm wondering how..

i would like to do something like :

linux:currentdir/$ POST http://www.example.com/upload.php > myFileToUpload

I guess i had probably to encode the file, i'm right, it's in base64 ? Isn't it ? I also read in the man that i'm able to set the Content-Type header, should it be set with 'multipart/mixed' ?

Thank you.

Upvotes: 0

Views: 1400

Answers (1)

Aiden Bell
Aiden Bell

Reputation: 28386

You might consider looking into Curl. It is much more robust. An example of automating a file-upload form submission would be:

<form method="POST" enctype='multipart/form-data' action="upload.cgi">
  <input type=file name=upload>
  <input type=submit name=press value="OK">
</form>

Then use the command

curl -F upload=@localfilename -F press=OK http://www.example.com/form.cgi

Upvotes: 1

Related Questions