[Q]cURL Download from php and output progress
Posted: Sun Feb 06, 2011 9:36 am
Hello every one, =]
Im having a problem retrun the progress of an PHP cURL script, well I just couldn't find how to.
P.S: I do know that I will have to use javascript to present the output.
I wrote the following: (which as i mentioned download file from ftp to the server using cURL functions);
Thank you =]
Im having a problem retrun the progress of an PHP cURL script, well I just couldn't find how to.
P.S: I do know that I will have to use javascript to present the output.
I wrote the following: (which as i mentioned download file from ftp to the server using cURL functions);
Code: Select all
<?php
$file_target = "ls-lR.gz";
$file_source ='ftp://example.co.il/filename.exe';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $file_source);
curl_setopt($ch, CURLOPT_USERPWD, 'username:password');
$fp = fopen($file_target, 'w');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec ($ch);
$output = 'true';
if (curl_errno($ch)) {
trigger_error('CURL error: "' . curl_error($ch) . '"', E_USER_WARNING);
$output = 'false';
}
curl_close ($ch);
fclose($fp);
echo $output;
?>