How does one POST a binary file stored locally using php-curl?

curl, php, post

Solution

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

Problem

I wish to issue the following curl request using php-curl: ``` curl "http://www.example.com/" -F "file=@foo.ext" ``` 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?

Original source