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

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
GeniusTse
Forum Newbie
Posts: 2
Joined: Fri May 30, 2008 2:43 am

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

Post 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 ?
User avatar
LuckyShot
Forum Newbie
Posts: 13
Joined: Thu Sep 25, 2008 5:02 pm
Location: Barcelona

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

Post 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?
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

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

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