3

I wish to issue the following curl request using php-curl:

curl "http://www.example.com/" -F "[email protected]"

How do I need to set this up in PHP (using curl_init, _setopt, etc.), assuming foo.ext lives on the machine from which I'm issuing the request?

1 Answer 1

5

you'd use

curl_setopt($curl_handle, CURLOPT_POST, TRUE);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, array('file' => '@foo.ext'));

plus whatever options you need. Relevant docs here: http://php.net/curl_setopt

Sign up to request clarification or add additional context in comments.

3 Comments

Looks like I didn't scour that document closely enough last time I looked. Thanks for the quick answer!
The '@' sign should precede the file name, not the parameter name. See here.
Right you are, Pang. Can you edit your answer for posterity, Marc?

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.