Originally posted by wcleung9
In fact I have found some open source code which, in co-operation with javascript, allows a running PHP program shows its running progress in client's browser in the form of a progress bar. The main idea is the same as yours: making use of flush().
But this should not work. In my understanding, the time during which the file is uploading, is actually the time in which the http request is sending from client to server. The receivefile.php will not start running until the whole request is sent. That means, when receivefile.php start to run, the file-upload process has already finished. receivefile.php only helps save the uploaded file on the filesystem.
As you said, the next php file has not been loaded before the upload completes, so maybe work in another way around.
When user press the submit button, use javascript to popup another window (button.onClick... something like that) just showing the word "Uploading / Processing / Please wait..". Or you can also show a rough estimate on the transfer time (eg. 32secs for 1MB @ 256kb/s) so that user can get an idea on the waiting time and won't lose temper.
If you know the exact file path on the server while receiving the file, you can even provide more real time information to user (eg. 33% uploaded) by using another script to monitor the file size on the server. However as I know, php create a temporary file with random name during receiving file, so you probably cannot work in this way.