Using CURL to upload files to a serverJun 292017
Original posted on 29th March 2017 at http://rahul2001.com/weblog/2017/03/using-curl-to-upload-files-to-server
I have a script which runs remotely on a school PC, which is part of a renderfarm I build for my friend. I needed it to be able to upload the rendered file to my server. Here's how I managed to do this:
On my server I have a page with this simple form to upload the file:
<form action="" method="POST" enctype="multipart/form-data"> <input type="file" name="rfile" /> <input type="submit"/> </form>
This following command send a file via a POST request:
curl --form firstname.lastname@example.org --form press=submit http://example.com/upload.php
This script is platform-independent. Enjoy!