File upload progress problems
Posted: Fri Nov 28, 2008 8:31 am
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:
Thanks in advance, Stephen.
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
Thanks in advance, Stephen.