I want to make a process bar that will show the uploading percentage & data size for server to server file transfer. I want to use this in this function:
<?php
function download_pretending($url,$user_agent) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
set_time_limit(3000); # 5 minutes for PHP
curl_setopt($ch, CURLOPT_TIMEOUT, 3000); # and also for CURL
$result =base64_encode(curl_exec ($ch));
curl_close ($ch);
if(!$handle = fopen(basename($url), 'w+'))
{
echo "Cannot open file ".basename($url);
exit;
}
if (fwrite($handle, $result) === FALSE) {
echo "Cannot write to file ".basename($url);
exit;
}
echo "Compleated ".basename($url);
fclose($handle);
}
?>
Please help me & thanks in advance.