0

Using a very simple PHP server:

<?php
$file = date("YmdHisms") . ".jpg";
file_put_contents($file, file_get_contents("php://input"));
?>

I'm trying to upload images using cURL:

curl --data "/path/to/image.jpg" 'http://192.168.1.3'

or:

upload multiple files to php server using curl command line

curl -F "[email protected]" 'http://192.168.1.3'

or:

cat image.jpg | curl --data - 'http://192.168.1.3'

Files are getting created in my web sever directory, but the images don't seem to open? What am I getting wrong here?

2 Answers 2

1

Change the php code to

<?php
   $file = date("YmdHisms") . ".jpg";
   move_uploaded_file($_FILES['image']['tmp_name'], $file);
?>
Sign up to request clarification or add additional context in comments.

Comments

0

Try this:

curl -i -X POST -H "Content-Type: multipart/form-data" -F "[email protected]" http://192.168.1.3

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.