Skip to main content

PHP extension upload progress - returning negative total bytes and time remaining


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.


Source: Tips4all

Comments

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

    $filesize = filesize($large_file);
    printf(Filesize: %.0f\n", $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 ?

    ReplyDelete

Post a Comment

Popular posts from this blog

[韓日関係] 首相含む大幅な内閣改造の可能性…早ければ来月10日ごろ=韓国

div not scrolling properly with slimScroll plugin

I am using the slimScroll plugin for jQuery by Piotr Rochala Which is a great plugin for nice scrollbars on most browsers but I am stuck because I am using it for a chat box and whenever the user appends new text to the boxit does scroll using the .scrollTop() method however the plugin's scrollbar doesnt scroll with it and when the user wants to look though the chat history it will start scrolling from near the top. I have made a quick demo of my situation http://jsfiddle.net/DY9CT/2/ Does anyone know how to solve this problem?

Why does this javascript based printing cause Safari to refresh the page?

The page I am working on has a javascript function executed to print parts of the page. For some reason, printing in Safari, causes the window to somehow update. I say somehow, because it does not really refresh as in reload the page, but rather it starts the "rendering" of the page from start, i.e. scroll to top, flash animations start from 0, and so forth. The effect is reproduced by this fiddle: http://jsfiddle.net/fYmnB/ Clicking the print button and finishing or cancelling a print in Safari causes the screen to "go white" for a sec, which in my real website manifests itself as something "like" a reload. While running print button with, let's say, Firefox, just opens and closes the print dialogue without affecting the fiddle page in any way. Is there something with my way of calling the browsers print method that causes this, or how can it be explained - and preferably, avoided? P.S.: On my real site the same occurs with Chrome. In the ex