我正在使用 PHP 上传进度扩展来检索有关正在上传到我的网络系统的文件的信息。但是,对于大于 2GB 的文件,总字节数和剩余时间字段将作为负数返回。
Apache 已设置为确保可以将最大 3GB 的文件上传到网站。我已经测试过这个并且它有效。然而,这纯粹是错误返回的报告。
我想知道这是否与 PHP 值的限制有关以及可以采取什么措施来解决它。我相信系统正在使用 64 位整数。如下所示:
echo "PHP_INT_MAX: " . PHP_INT_MAX;
// PHP_INT_MAX: 9223372036854775807
以下是有关进度条如何工作和安装的一些额外信息: http://www.ultramegatech.com/blog/2010/10/create-an-upload-progress-bar-with-php-and-jquery/
要获取信息,我只需调用扩展函数:
$status = uploadprogress_get_info($unique_form_id);
返回总字节数、预计剩余时间、当前字节数等,如下所示(总字节数为负):
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"
}
更新(2012 年 1 月 6 日):我还联系了此扩展的开发人员,看看他们是否可以分享任何见解。
更新(2012 年 1 月 9 日):扩展的开发人员已回复,指出存在有关此问题的现有票证:https://bugs.php.net/bug.php?id=59918
更新(2012 年 1 月 16 日):已设法消除扩展程序返回的负值。然而,与 Windows 在属性窗口中显示的数字相比,返回的数字与实际的总字节数相差甚远。
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)
使用浮点数并删除小数 - 这适用于这些较大的数字:
此答案将确认您是否使用 64 位整数: 如何在 PHP 上使用 64 位整数?
注意: 尽管该问题还有另一个答案,似乎表明 64 位整数在 Windows 上不可用 - 您使用什么操作系统?
Use a float and remove the decimals - this will work for these larger numbers:
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 ?