Hey guys,
I need some advice I am trying to develop a service which tranfers files from one place to the next for converting. I developed a progress display sequence in PHP which uses sleep() and flush() loop to run a progress bar update for the transfer. Now the thing is that some of these files maybe large ( <= 10M).
is this a good/ effective or efficeint implementation to use?
Any suggestions pros or cons on this?
Kendall
Using sleep() for delayed output effects
Moderator: General Moderators
Re: Using sleep() for delayed output effects
Only one that springs to mind is the possibility that your sleep() may cause the user agent to assume the connection has been lost (if long enough of a delay.)
Perhaps an asynchronous poll would be better than using sleep()/flush() though. Using sleep() just feels dirty to me.
Perhaps an asynchronous poll would be better than using sleep()/flush() though. Using sleep() just feels dirty to me.
- kendall
- Forum Regular
- Posts: 852
- Joined: Tue Jul 30, 2002 10:21 am
- Location: Trinidad, West Indies
- Contact:
Re: Using sleep() for delayed output effects
Jenks,
coool. I am using it with an asynchronous upload function one thing im noticing that my server seems to "slow down". Well i'm using it on local server and this is not something I would use to benchmark anything.
coool. I am using it with an asynchronous upload function one thing im noticing that my server seems to "slow down". Well i'm using it on local server and this is not something I would use to benchmark anything.
- kendall
- Forum Regular
- Posts: 852
- Joined: Tue Jul 30, 2002 10:21 am
- Location: Trinidad, West Indies
- Contact:
Re: Using sleep() for delayed output effects
I notice that with the script on sleep() I apparently can't use it until its finished. the sleep is actually from an included file. Is there a way around this?
Re: Using sleep() for delayed output effects
There's jquery plugins that do a lot of stuff like display ETA and such and have smoother animation, would not try to achieve "delayed output effects" in PHP, its a "smell" ( less then optimal design ).
For ex. when uploading videos to youtube it goes into a "processing" state, it could either poll via ajax or the user could just check back in several minutes to view the updated status ( the task should happen in the background, not in a process the user can stop halfway thru )
For ex. when uploading videos to youtube it goes into a "processing" state, it could either poll via ajax or the user could just check back in several minutes to view the updated status ( the task should happen in the background, not in a process the user can stop halfway thru )
- kendall
- Forum Regular
- Posts: 852
- Joined: Tue Jul 30, 2002 10:21 am
- Location: Trinidad, West Indies
- Contact:
Re: Using sleep() for delayed output effects
I am thinking that it maybe best. I was really trying to avoid any sort of non-php option to keep a consitency avoiding having to re-invent what I already had just to accomodate having to use JS library to achieve this process....alast i guess i have no choice...
Thanks
Thanks
Re: Using sleep() for delayed output effects
Holding the connection open will hurt your server capacity. You can use a library with a bit of flash to do this. LIke YUI Uploader.
- kendall
- Forum Regular
- Posts: 852
- Joined: Tue Jul 30, 2002 10:21 am
- Location: Trinidad, West Indies
- Contact:
Re: Using sleep() for delayed output effects
I am realizing this....I went ahead and installed the uploadprogress PECL extension. I have decided to $_POST instead of FTP...don't know how efficient is this