capturing curl stdout into variable in PHP
**Task**

Downloading binary files from a remote media processing server to a web server. 

**This works but I cannot capture the curl stdout output**

$result = shell_exec('curl -v  http://domain.com/images/dir/dir/dir/file.jpg  --user username:password -o /usr/www/htdocs/images/dir/dir/dir/file.jpg');

Note:
I have had no luck using the PHP curl wrapper methods for this task, partly because I've never used PHP curl wrappers for FTP downloads.

**Question**
Can someone explain how to capture the output from the command that I am shelling out to or a simple example using PHP curl wrappers?

Here is what I tried and the part I'm stumped on is how to get the new file placed on the target server -   The line that's wrong is the CURLOPT_FILE line. I don't want to have to create a stub file, open it and then write to it.

$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, $ftpserver.$file['directory'].$filename); #input
curl_setopt($curl, CURLOPT_FILE, $dest); #output
curl_setopt($curl, CURLOPT_USERPWD, "$user:$password");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);

Thanks

capturing curl stdout into variable in PHP
===

**Task**

Downloading binary files from a remote media processing server to a web server. 

**This works but I cannot capture the curl stdout output**

$result = shell_exec('curl -v  http://domain.com/images/dir/dir/dir/file.jpg  --user username:password -o /usr/www/htdocs/images/dir/dir/dir/file.jpg');

Note:
I have had no luck using the PHP curl wrapper methods for this task, partly because I've never used PHP curl wrappers for FTP downloads.

**Question**
Can someone explain how to capture the output from the command that I am shelling out to or a simple example using PHP curl wrappers?

Here is what I tried and the part I'm stumped on is how to get the new file placed on the target server -   The line that's wrong is the CURLOPT_FILE line. I don't want to have to create a stub file, open it and then write to it.

$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, $ftpserver.$file['directory'].$filename); #input
curl_setopt($curl, CURLOPT_FILE, $dest); #output
curl_setopt($curl, CURLOPT_USERPWD, "$user:$password");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);

Thanks
