douyinlai2169 2012-04-11 10:23
浏览 15

复制文件服务器到服务器的简单进度条

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.

  • 写回答

1条回答 默认 最新

  • draj840143 2012-04-11 10:35
    关注

    Sounds like you need CURLOPT_PROGRESSFUNCTION. Theres some info on it here: PHP curl_setopt() CURLOPT_PROGRESSFUNCTION and here: http://curl.haxx.se/libcurl/c/curlgtk.html

    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号