PDA

View Full Version : [PHP] How do I...?



Jxhn
21-12-2008, 09:47 AM
Say I have a large script which will take a long time to finish running, how do I make it so that it can run without the user loading the page and can just show its progress everytime the user refreshed.

An example of what I want is the remote uploading on rapidshare.

Jackboy
24-12-2008, 09:23 AM
Say I have a large script which will take a long time to finish running, how do I make it so that it can run without the user loading the page and can just show its progress everytime the user refreshed.

An example of what I want is the remote uploading on rapidshare.

Are you talking about a cron? :S

RichardKnox
24-12-2008, 09:27 AM
Are you talking about a cron? :S

He means like say it's a script that runs for an hour, but every time the user refreshes the page it'll show the LATEST progress e.g. 50% done (like a program installer.)

That's AFAIK what he wants.

Jackboy
24-12-2008, 10:09 AM
He means like say it's a script that runs for an hour, but every time the user refreshes the page it'll show the LATEST progress e.g. 50% done (like a program installer.)

That's AFAIK what he wants.

Ohhh i see. Sorry for my misunderstanding hehe

Moh
24-12-2008, 10:24 AM
Humm, I duno how you would do it as Rapid Share is on a remote server.

But heres how you would do it.

- Find out the size of the file.
- Every second, see how big the uploaded file is.

Then divide it by 100 or something :P

So if you was uploading a file called illegalsoftwareftw.rar and that was been uploaded to www.domain.com/uploads/illegalsoftwareftw.rar, you find the file size of just illegalsoftwareftw.rar, then every second fine the size of www.domain.com/uploads/illegalsoftwareftw.rar.

Hope that makes sence :P

Trigs
24-12-2008, 06:47 PM
www.php.net/filesize

Dentafrice
25-12-2008, 02:40 PM
Humm, I duno how you would do it as Rapid Share is on a remote server.

But heres how you would do it.

- Find out the size of the file.
- Every second, see how big the uploaded file is.

Then divide it by 100 or something :P

So if you was uploading a file called illegalsoftwareftw.rar and that was been uploaded to www.domain.com/uploads/illegalsoftwareftw.rar (http://www.domain.com/uploads/illegalsoftwareftw.rar), you find the file size of just illegalsoftwareftw.rar, then every second fine the size of www.domain.com/uploads/illegalsoftwareftw.rar (http://www.domain.com/uploads/illegalsoftwareftw.rar).

Hope that makes sence :P
Uploading doesn't work that way though.

When you're uploading it to the server, you're first having to put the ENTIRE file into an HTTP request.

Then you're sending that HTTP request to the server, with the file data in it.. (file data, filename, and all the headers).

Once that gets to the server, it's automatically re-rerouted and saved into a tmp directory (that's what that tmp_name is for)..

It's not directly stored in an upload directory until your script tells it to do so, whether through your own custom process, or (is_uploaded_file()/move_uploaded_file() )

So really checking the file size of something every few seconds.. isn't going to matter in a case like this, as by the time it's already in the tmp directory / your directory.. it's already been processed and fully uploaded and stored.

Want to hide these adverts? Register an account for free!