Link to home
Start Free TrialLog in
Avatar of Jeremy Daley
Jeremy DaleyFlag for United States of America

asked on

pure PHP upload progress bar

i'm having a hard time finding any kind of upload progress bar that will work in my case.

every example i see requires installing a patch, etc. etc. on the server.

well, my site is hosted on godaddy.com so i don't believe there is a whole lot of control that i have over this.

the biggest problem seems to be... i don't know how to retrieve the amount uploaded during the upload.

i could start with an iframe as an upload forms target. a <div> to display progress. and hopefully be able to send requests to a php file that can get the uploaded amount and then send a response.

am i asking for the impossible? these sample scripts seem to be a nuisance for my particular situation.
Avatar of m1tk4
m1tk4
Flag of United States of America image

>> the biggest problem seems to be... i don't know how to retrieve the amount uploaded during the upload.

And unfortunately that's the one you can't solve. Apache (web server) does not pass control to PHP until the file is fully uploaded.
Avatar of Jeremy Daley

ASKER

so do you know what i might be able to do considering my shared hosting?
>>so do you know what i might be able to do considering my shared hosting?

Yes. Nothing.
The communication is as follows.

Client makes a GET request for a form which allows the user to upload a file.
Server examines requests and supplies the HTML file or launches the PHP script which creates the HTML and then the server sends this.
Client renders HTML.
User fills in form and selects a file to upload.
User presses submit.
Client makes a POST request to server.
Server starts receiving data and stores the data in its temp location (the specific directory may NOT be accessible to anything other than the web server whilst the upload is taking place.
Server will then launch the handler for the POST once the upload is completed. In the case of PHP, the $_FILES array will be populated.

At no stage does PHP get activated DURING or BEFORE the upload.

Without patching the server, there is no mechanism available.

If the patching was done, the mechanism is non-standard and may not be supported adequately within PHP.
okay... tell me this much...

if you were in my situation, and you had many a number of users that would be using your site to upload up to 10Mb Mp3 files... what would you do? an animation of some sort, possibly telling the amount of time that has elapsed?

do you think calling godaddy.com would solve anything? should i switch hosting with someone that YOU know may further help my situtation?
ASKER CERTIFIED SOLUTION
Avatar of Richard Quadling
Richard Quadling
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
And this doesn't look like it needs any patches to the server. Just Perl. Which should be there.
i've tried this and haven't had too much luck... but then again i wouldn't completely rely on that answer as a base for saying it doesn't work.

the installation instructions are sometimes really vague also and i'm not always sure how to find my temp directory, etc. my hosting account doesn't even have a cgi-bin folder anywhere, but that's not to say i don't have perl support.

i'll look at this even further and see what i can make out of it.

i do want to ask another question though... is there something that i can setup in the form that would stop the upload pretty much as soon as it starts? like if i set up the max_upload_size (not sure if that's the right fieldname), or perhaps the form's enctype, might it upload for a second and then immediately fail allowing me to execute my php and still retrieve file size? can i detect connection speed somehow without it basing itself off of upload progress/elapsed time?

if it was possible, this way, i could get the filesize at least and let the user know an approximate time frame, then send a RE-submittal of the form.

like i said RQuadling, let me look more into raditha's solution, but i may be asking for further assistance for a proper setup. thanks
The max_upload_size issue is not guaranteed to be supported by all browsers. It cannot realistically be relied upon.

good point
well, i'm certain i have everything required to run megaupload progressbar. my original hosting package didn't have any perl support whatsoever. now i have support for the following:

 - Perl(w/FASTCGI)
 - Python CGI
 - Java
 - Ruby CGI
 - Ruby on Rails(w/FASTCGI)

now i have uploaded all the files required to run the demo on my server to the locations that the installation documentation instructs, but for some reason i keep getting internal server errors.

i have set full access on the cgi bin and also confirmed all the paths to which the files are pointing to. what other reasons might i be getting this error?

(50pt increase)
What you should've really done is close this one and open a second one - remember that EE is both for you to get your problems solved and to leave a good and consistent knowledge base for anyone who might have the same problems in the future. "Packing" one thread with unrelated problems isn't really such a good thing.
i don't understand how this is unrelated. my goal is to get an upload progress bar on my site using php.

if using the mega upload progress bar was suggested as a solution to my problem, is it too much to ask for support regarding that particular suggestion?
Avatar of CraigHarris
CraigHarris

You can make a client-side progress bar using JavaScript - whatever you do server side will still need an action performed client side, so it would be difficult to avoid JavaScript anyway ---- you could use AJAX techniques to check the progress of the file IF it is constantly being written to temp folder AND you have permission to read that folder .... otherwise, you need JavaScript to handle the actual upload, which isn't trivial for security reasons.
i pretty much understand that concept... it's the reading of the file's progress that is causing me the strife.
Not being picky, but you are no longer using PHP to deal with the progress bar.

i started with megauploader and switched over to uber uploader. it's all on sourceforge.net.

actually i did start using AJAX to embed the bar into my page and sent requests via JS to the cgi file which returned all the vitals.

it worked pretty good as far as that went... but it was a little quirky dealing with my file and that's why i switched.

hopefully i can now work on ways to speed up the uber uploader. i appreciate your help. thanks