deansatch Posted January 18, 2010 Share Posted January 18, 2010 I was wondering, if you HAVE TO accept uploads of large files e.g. 300MB via php, chances are it will time out. But, is there some way of using sleep() to keep it going? I haven't ever gotten round to using sleep() but I am intrigued by it. Quote Link to comment Share on other sites More sharing options...
trq Posted January 18, 2010 Share Posted January 18, 2010 All sleep does is pauses a script so it will do pretty much the opposite of what you want. Large files ought to be uploaded via ftp. Its not called file transfer protocol for nothing. Quote Link to comment Share on other sites More sharing options...
Birdmansplace Posted January 18, 2010 Share Posted January 18, 2010 Large files ought to be uploaded via ftp. Its not called file transfer protocol for nothing. Quote Link to comment Share on other sites More sharing options...
deansatch Posted January 18, 2010 Author Share Posted January 18, 2010 Notice how I capitalised "HAVE TO". If it is a site like megaupload or yousendit it would not be done via ftp. Does sleep() not pause the script and then when it restarts the timeout is set back to the beginning too? Quote Link to comment Share on other sites More sharing options...
Birdmansplace Posted January 18, 2010 Share Posted January 18, 2010 integrate php ftp. I have never done it because i dont need it Quote Link to comment Share on other sites More sharing options...
deansatch Posted January 18, 2010 Author Share Posted January 18, 2010 integrate php ftp. I have never done it because i dont need it I looked into php ftp and from what I can gather, you can't "UPLOAD" via php ftp, you can upload via http (hence my post) then use ftp to transfer it from one server to another (rendering it a pretty useless function in my eyes). Quote Link to comment Share on other sites More sharing options...
Adam Posted January 18, 2010 Share Posted January 18, 2010 Does sleep() not pause the script and then when it restarts the timeout is set back to the beginning too? Where did you read that? I believe you're thinking of set_time_limit there; that resets the counter back to 0 when called. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted January 18, 2010 Share Posted January 18, 2010 Your php script that is the target of the upload form is not executed until after the file has been completely uploaded. The act of receiving the uploaded file is handled by the web server and is basically out of your control (except for what you can influence by stetting some of the php settings), unless you do something to cause the normal handling of the upload to be replaced with your own code. See this thread for how you could do something like that - http://www.phpfreaks.com/forums/index.php/topic,284122.0.html Quote Link to comment Share on other sites More sharing options...
deansatch Posted January 18, 2010 Author Share Posted January 18, 2010 So what use would there be for sleep() if all it does is delay the script? Surely we want our scripts o execute as quickly as possible? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted January 18, 2010 Share Posted January 18, 2010 You are the one who suggested using sleep()... What exact problem or error are you having that you are trying to solve? Quote Link to comment Share on other sites More sharing options...
deansatch Posted January 18, 2010 Author Share Posted January 18, 2010 I haven't actually got a problem, I am working something out in theory before starting a script to get the best way to do it - i.e. huge file uploads via a browser. I suggested sleep() as it is something I came across and wondered if a)it would help this and b)what is its uses? Quote Link to comment Share on other sites More sharing options...
trq Posted January 18, 2010 Share Posted January 18, 2010 Well, as its description implies..... sleep — Delay execution All it does is pause a script. Quote Link to comment Share on other sites More sharing options...
deansatch Posted January 18, 2010 Author Share Posted January 18, 2010 The only use I can imagine for sleep() is if you are limited to say 1000 emails per hour and you have written a mailing script with more than 1000 recipients you would mail 1000 then slepp() for an hour then mail another 1000 etc... But wouldn't that mean your browser would be open for hours and timeouts would still occur? Quote Link to comment Share on other sites More sharing options...
trq Posted January 18, 2010 Share Posted January 18, 2010 Yes it would. As I said in my intial reply. sleep(0 is probably more useful in a shell environment, not really much use for it within the web. Quote Link to comment Share on other sites More sharing options...
oni-kun Posted January 18, 2010 Share Posted January 18, 2010 The only use I can imagine for sleep() is if you are limited to say 1000 emails per hour and you have written a mailing script with more than 1000 recipients you would mail 1000 then slepp() for an hour then mail another 1000 etc... But wouldn't that mean your browser would be open for hours and timeouts would still occur? No, It'd be recommended to sleep for example 10ms between execution of mail() to guard against problems, another use of sleep() can be to delay execution of a set of commands, such as $fp = fopen('?doCronjob', 'r') sleep(1000); //Wait for reply file_get_contents(/usr/var/cronlog.log); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.