Re: File uploads - progress reporting gets stuck short of 100%



John Geddes wrote:
AIUI PHP 5.2 provides hooks for monitoring file upload progress, but you need an extension to access the data.

I've tried both the PERC "uploadprogress" and "apc" extensions for creating a progress bar during a file upload. With both I hit the same problem - can anyone help?

Both extensions involve repeated AJAX (http or iFrame) calls to a progress-checking php page, which uses an extension-specific function to return (among other things) the bytes uploaded so far, and the size of the file in bytes.

As the initial file upload progresses, up goes the percentage ... until shortly before 100%. But once the file is uploaded, it needs to be moved (and checked) from its temporary location - or else it will be deleted when the upload-form-processing page closes. And this is where the problem is. I want to be able to show when uploading is complete, and replace the progress bar with the status "Processing" until the whole process is finished. But that isn't as easy as it seems.

PHP (at least as it runs on my WAMP setup) seems to refuse calls to the progress-checking page whilst the operation "move_uploaded_file" is taking place. And with a large file (or, presumably, modest sized files on a busy server), that operation takes quite a while. During this time, the user has seen the progress bar whizz up from zero to say 95% (the value returned on the last progress-check before the file was finished), but then sees progress appear to stick at 95%. Only when the "move_uploaded_file" operation is complete will php process the progress-checking page calls - and at that point, the progress can be updated to show the file fully uploaded. But it looks dreadful, and an impatient user might give up having presumed that something had gone wrong.

I've tried a "sleep" for 5 seconds before the move_uploaded_file operation, but that too locks out the progress-checking page.

Are there any php.ini settings that will change this? Is there any other way to report back that the initial upload is finished before the move_uploaded_file is complete?

The least-bad solution I've found is to do a "rename" rather than a "move_uploaded_file" - it seems considerably quicker so the unwanted effect is less pronounced. But this has security implications.

Ideas?

John Geddes
England.


Are you using sessions? PHP will single thread access to the same session data.

Otherwise, I wouldn't expect move_uploaded_data to take very long - at least it doesn't on my systems, even for files sizes of several mb.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================

.



Relevant Pages

  • Re: [PHP] Re: progress in PHP
    ... The problem is not showing progress but rather tracking progress. ... What you seem to not be understanding is that PHP handles uploads ... by the time a PHP script that gets the submitted upload ... The Perl solution is based on a script that handles and tracks the ...
    (php.general)
  • File uploads - progress reporting gets stuck short of 100%
    ... I've tried both the PERC "uploadprogress" and "apc" extensions for creating a progress bar during a file upload. ... Both extensions involve repeated AJAX calls to a progress-checking php page, which uses an extension-specific function to return the bytes uploaded so far, and the size of the file in bytes. ...
    (alt.php)
  • Re: [PHP] Re: progress in PHP
    ... here is a link to a PHP extension which enables the ability to ... track the progress of a PHP upload. ... >> How does perl show progress of the upload if it is a server side scripting ...
    (php.general)
  • Re: Is there http file upload lib which tracks upload progress?
    ... I'm currently using the http lib to upload files. ... progress info exporting is only able to track the progress of files as they download, ...
    (comp.lang.tcl)
  • net::FTP and progressbar
    ... I am looking for a way to add a progress bar to my perl net::FTP ... I am able to see the bar but not the actual progress, ... and after upload ... anybody add a sucessfull script working ...
    (perl.beginners)