How to upload a file via the command line using cURL; Upload an image using curl


To upload a file using the command line, do the following:

curl "" -F myfile=@"/path/to/file" Example: curl "" -F myfile=@"~/Desktop/image.png" And using authentication: curl -u username:password "" -F myfile=@"~/Desktop/image.png" NOTE: Change myfile to the file input value name. <input name="myfile" type="file" /> // upload.php var_dump($_POST); var_dump($_FILES);
Posted . Did this help you? Please let me know with a comment. Thank you

Comments (RSS)

  1. anonymous

    When I try this, I just get the message: array(0)

    Any ideas?! Thanks!

  2. anonymous


    try var_dump($_POST) and var_dump($_GET); to see if at least something is coming through

  3. anonymous

    Thanks :) .. it helped.

  4. anonymous

    was about to pull my hair out. Stumbled upon your page. Works perfectly.