File upload progress problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

File upload progress problems

Post 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.
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: File upload progress problems

Post 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.
Post Reply