我想制作一个能够显示上传百分比的流程栏。服务器到服务器文件传输的数据大小。我想在这个函数中使用它:
<?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);
}
?>
请帮助我&amp;提前谢谢。
答案 0 :(得分:0)
听起来你需要CURLOPT_PROGRESSFUNCTION。这里有一些信息:PHP curl_setopt() CURLOPT_PROGRESSFUNCTION和这里:http://curl.haxx.se/libcurl/c/curlgtk.html