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.
LVL 4
Jeremy DaleySenior DeveloperAsked:
Who is Participating?
 
Richard QuadlingSenior Software DeveloperCommented:
http://www.raditha.com/php/progress.php

This uses Perl rather than PHP to deal with the upload. But then passes it all over to PHP when uploaded.

This example uses an auto-refresh to get the details back to the user.

This could be extended to use an AJAX mechanism to not have the page refresh.

But I think you CANNOT do this with PHP alone.
0
 
m1tk4Commented:
>> 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.
0
 
Jeremy DaleySenior DeveloperAuthor Commented:
so do you know what i might be able to do considering my shared hosting?
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

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

Yes. Nothing.
0
 
Richard QuadlingSenior Software DeveloperCommented:
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.
0
 
Jeremy DaleySenior DeveloperAuthor Commented:
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?
0
 
Richard QuadlingSenior Software DeveloperCommented:
And this doesn't look like it needs any patches to the server. Just Perl. Which should be there.
0
 
Jeremy DaleySenior DeveloperAuthor Commented:
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
0
 
Richard QuadlingSenior Software DeveloperCommented:
The max_upload_size issue is not guaranteed to be supported by all browsers. It cannot realistically be relied upon.

0
 
Jeremy DaleySenior DeveloperAuthor Commented:
good point
0
 
Jeremy DaleySenior DeveloperAuthor Commented:
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)
0
 
m1tk4Commented:
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.
0
 
Jeremy DaleySenior DeveloperAuthor Commented:
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?
0
 
CraigHarrisCommented:
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.
0
 
Jeremy DaleySenior DeveloperAuthor Commented:
i pretty much understand that concept... it's the reading of the file's progress that is causing me the strife.
0
 
Richard QuadlingSenior Software DeveloperCommented:
Not being picky, but you are no longer using PHP to deal with the progress bar.

0
 
Jeremy DaleySenior DeveloperAuthor Commented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.