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 "https://www.example.com/upload.php" -F myfile=@"/path/to/file"
Example:
$ curl "https://www.example.com/upload.php" -F myfile=@"~/Desktop/image.png"
And using authentication:
$ curl -u username:password "https://www.example.com/upload.php" -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);
4 comments
When I try this, I just get the message: array(0)
Any ideas?! Thanks!
@array(0)
try
var_dump($_POST)
andvar_dump($_GET);
to see if at least something is coming throughThanks :) .. it helped.
was about to pull my hair out. Stumbled upon your page. Works perfectly.
Leave a Reply