Page 1 of 1

File upload progress problems

Posted: Fri Nov 28, 2008 8:31 am
by impulse()
I'm writing my own upload progress bar and I'm hitting a problem with working out the size of an uploaded file before it's finished uploading to the server.

I would work out the % complete using this calculation: progress = (<size of file> / <ls -s /tmp/<tmpFileName>> * 100)

But as far as I'm aware PHP doesn't know the temp location or the file size until the file has been uploaded at which point a progress bar is useless as it'll just be 100%.

I have the files setup at the moment as a index page that has an iFrame with the PHP uploader inside and the index page also has an AJAX script which calls a PHP page which runs "ls -s <temp file location>" every second.

So at the moment I have the following problems:
  • I can't access the temporary location of the file (eg: /tmp/dge323ed) in the page which runs "ls -s <temp location>"
  • I can't find the file size until the file has finished uploading
Do you have any suggestions to making this work as I want it to, or do I need to go a completely different route to make this work?

Thanks in advance, Stephen.

Re: File upload progress problems

Posted: Fri Nov 28, 2008 8:36 am
by Mark Baker
impulse() wrote:But as far as I'm aware PHP doesn't know the temp location or the file size until the file has been uploaded at which point a progress bar is useless as it'll just be 100%.
Basically , you're correct. Take a look at the APC documentation, that claims to be able to do upload progress status.