tags:

views:

79

answers:

2

hey guys, i know there are a lot of "for-me-too-complicated" versions of progress-bars for php uploads out there.

however i have only a really basic knowledge of php and i have no idea how to implement this stuff.

i did a working file-upload script that transferres files from the user to my ftp-server. i'm using ftp_connect and ftp_put to do so.

i wonder how complicated it is to print a SIMPLE percentage value on to the page, to let the user know how far the upload has progressed.

i don't want any animated javascript stuff, just a simple percentage that shows the progress.

do you know a tutorial or something, or can you maybe give me a little explanation how i could do that. at least which methods return a progress value.

thank you in advance,matt

A: 

PHP/Apache talks to the client in a single request only. There is no simple way to actually have the client (know) how far the server is in the process. On uploads the file travels from the client to the server, so we generaly use Flash that can give us that information.

client (flash) -> server

What you are asking is something a bit fancier

client -> server -> ftp

And you want to know the progress between the server and the FTP. Mind you that even if you don't realize it the files are actually beeing transfered to the server and then from the server to the FTP server.

You will probably want to have the server update a database on given intervals with the progress so far and have the client AJAX the server to find out where the server is at.

You can also give socket.io a look!

Frankie
if I'm using ftp_put how can i have the server to update a database with the progress?
@mathiregister In a logical way you cant. You could actually jump up nethogs and capture the network usage of that process but it would be a bit messy and a not-so-good solution. Take a look at http://stackoverflow.com/questions/2885468/getting-ftp-put-progress were they hand out much better ideas.
Frankie
+1  A: 

I know you said the flash uploaders are too complicated for you and you need a simple solution but the truth is there are none. If you could start your project over I would recommend using some known CMS with file upload support.

I think you should really give something like uploadify another chance. If you have problems with it ask here! There is a uploadify tag and really helpful peoples.

edit after your commenht: As seen on this page theres the idea to use uploadify to get the file to yoru server and then move it normally using ftp to your other space/server.

Iznogood
soo... thank you, i've never heard of uploadify before and what i've seen now looks rather simple. However what i need to know first before i'm giving it a try is if this works with an FTP folder. I'm not much of an expert on that matter, but i don't know if it's possible to upload files with such a script to a ftp-server where i'm currently connecting with the ftp_connect method. Does this make a difference or is this just working. In my case it's propably even harder to implement uploadify because my upload-form is embedded in a wordpress page-template...
Is that folder on the webserver? If its a normal lamp setup it should be reachable for move_uploaded_files(). If tis not I do not know maybe you could ask a question about it. Or maybe look at why you need it to be ftp. Maybe you are taking the wrong approach for your needs.
Iznogood
i opened a new question. like i thought i'm having troubles implementing this to a wordpress page-template file! http://stackoverflow.com/questions/3649196/implementig-uploadify-in-a-wordpress-template
Appreciate if you accept this answer here. since you are done with it. :-)
Iznogood