duankeng1911 2012-01-06 09:39
浏览 35

PHP扩展上传进度 - 返回负的总字节数和剩余时间

I'm using the PHP upload progress extension to retrieve information about files being uploaded to my web system. However for files larger than 2GB the total bytes and time remaining fields are being returned as negative numbers.

Apache has been setup to ensure that files of a size up to 3GB can be uploaded to the website. I have tested this and it works. However it is purely the reporting that is coming back incorrectly.

I was wondering if this was anything to do with a limit on the PHP values and what could be done to fix it. I believe the system is using 64bit integers. As the following shows:

echo "PHP_INT_MAX: " . PHP_INT_MAX;
// PHP_INT_MAX: 9223372036854775807

Here's some extra information on how the progress bar works and is installed: http://www.ultramegatech.com/blog/2010/10/create-an-upload-progress-bar-with-php-and-jquery/

To get the information I simply call the extension function:

$status = uploadprogress_get_info($unique_form_id);

Which returns the total bytes, est time remaing, current bytes and more as shown below (with negative total bytes):

array(11) { 
    ["upload_id"]=> string(32) "ec75a30c24177ec1579aea93b56224f2" 
    ["fieldname"]=> string(9) "comp_data" 
    ["filename"]=> string(15) "Size_2-09GB.zip"
    ["time_start"]=> string(10) "1325851749"
    ["time_last"]=> string(10) "1325851758"
    ["speed_average"]=> string(5) "93011"
    ["speed_last"]=> string(6) "112618"
    ["bytes_uploaded"]=> string(6) "837105" 
    ["bytes_total"]=> string(11) "-2048166056" 
    ["files_uploaded"]=> string(1) "1" 
    ["est_sec"]=> string(9) "-76260228" 
} 

Update (6th Jan 2012): I have also contacted the developer of this extension to see if they can share any insight.

Update (9th Jan 2012): Developer of the extension has responded pointing out that there is an existing ticket regarding this issue: https://bugs.php.net/bug.php?id=59918

Update (16th Jan 2012): Have managed to get rid of the negative value being returned by the extension. However the number returned is way off what the actual number of total bytes in comparison to what Windows says it is in the properties window.

  • 写回答

1条回答 默认 最新

  • douxianglu4370 2012-01-06 09:43
    关注

    Use a float and remove the decimals - this will work for these larger numbers:

    $filesize = filesize($large_file);
    printf(Filesize: %.0f
    ", $filesize);
    

    This answer will confirm if you are using 64bit Integers : how to have 64 bit integer on PHP?

    Note: although there is another answer to that question which seems to indicate that 64bit integers are not available on windows - what OS are you using ?

    评论

报告相同问题?

悬赏问题

  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂