0

我想制作一个进程栏,显示服务器到服务器文件传输的上传百分比和数据大小。我想在这个函数中使用它:

<?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);
}
?>

请帮助我并提前感谢。

4

1 回答 1

0

听起来你需要 CURLOPT_PROGRESSFUNCTION。这里有一些关于它的信息:PHP curl_setopt() CURLOPT_PROGRESSFUNCTION和这里:http ://curl.haxx.se/libcurl/c/curlgtk.html

于 2012-04-11T10:35:09.540 回答