Page 1 of 1

A "Upload Progress Bar" Concept?? Anything wrong ?

Posted: Wed Sep 24, 2008 9:49 pm
by GeniusTse
I am trying to implement a PHP Upload Progress Bar using AJAX & iFrame technique, but not working
So I would like to ask you guys opinions about my idea.

My idea is that:
files:
Parent.php (embedded iFrame.php and includes progress.js and for showing Progress Bar)
iFrame.php (includes a html forms and handling POST action)
Progress.php (checks FILE SIZE of uploading image from upload temp dir)

When user UPLOAD a file
step 1) POST data from iFrame.php to iFrame.php and use session to store $_FILES info

Code: Select all

$_SESSION["files"] = $_FILES
step 2) iFrame.php using JavaScript to ask Parent.php to call Progress.php using Periodical AJAX (every 0.1s)
step 3) Progress.php check temp_file size and return progress to Parent.php using Json format

In above case, the Progress.php cannot read the $_SESSION["files"] properly (=null) until the whole upload progress complete.
does my idea has any mistakes ?

Re: A "Upload Progress Bar" Concept?? Anything wrong ?

Posted: Thu Sep 25, 2008 5:59 pm
by LuckyShot
Hi GeniusTse,

I guess PHP is still not that powerful. Maybe you should search for some open source Flash code to upload files. There are some Java applets too.

Can you use Flash/Java for your page or you really need it to be in PHP?

Re: A "Upload Progress Bar" Concept?? Anything wrong ?

Posted: Thu Sep 25, 2008 7:57 pm
by Eran
$_FILES gets populated only at the end of the file upload and only for the script that is receiving the file. There is a way to this with PHP, and you can read about it on this blog post by Martin Jansen