gazfocus Posted December 18, 2008 Share Posted December 18, 2008 I have created an upload form which uses ftp_put in order to upload files to my website as my hosts maximum php file upload size is 2MB and I do not have root access to the php.ini file. This works great on small files but most of the files that will be uploaded will be around 15MB-30MB and because the form uses method="post" it times out after a couple of minutes. Does anyone know if it's possible to change the timeout length? Is there a function that can split up the file into 2MB chunks and reassemble it on the server (as with TCP packets)? Also does anyone know how I can create a progress bar for the upload? Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/137541-uploading-files-wit-ftp_put-but-times-out/ Share on other sites More sharing options...
.josh Posted December 18, 2008 Share Posted December 18, 2008 set_time_limit might work for you. Quote Link to comment https://forums.phpfreaks.com/topic/137541-uploading-files-wit-ftp_put-but-times-out/#findComment-718839 Share on other sites More sharing options...
gazfocus Posted December 18, 2008 Author Share Posted December 18, 2008 set_time_limit might work for you. I've just done a bit of research on set_time_limit but it looks like it doesn't override the HTTP timeout Quote Link to comment https://forums.phpfreaks.com/topic/137541-uploading-files-wit-ftp_put-but-times-out/#findComment-718852 Share on other sites More sharing options...
premiso Posted December 18, 2008 Share Posted December 18, 2008 set_time_limit might work for you. I've just done a bit of research on set_time_limit but it looks like it doesn't override the HTTP timeout The only way (which may not work I have mixed results) is set an increment timer in the code, and after x seconds echo a "." to the screen to keep the browser session alive... Something like this: <?php $sizeTime = 1000; // set size time to 1,000 seconds for fun while ($x) { echo "."; sleep(30); // sleep for 30 seconds. if (($i*30) == $sizeTime) { $x = false; } } echo "Finished"; ?> After the 1,000 seconds it should exit the loop and display "Finished" Granted I have never used this with an upload script, only a large loop script. You may want to look into an AJAX/Flash uploader as I think you can keep those alive and upload about any size file you want...I have never used either but yea. Quote Link to comment https://forums.phpfreaks.com/topic/137541-uploading-files-wit-ftp_put-but-times-out/#findComment-718909 Share on other sites More sharing options...
JonnoTheDev Posted December 18, 2008 Share Posted December 18, 2008 Can you not use an .htaccess file to override the php.ini/httpd.conf directives? Quote Link to comment https://forums.phpfreaks.com/topic/137541-uploading-files-wit-ftp_put-but-times-out/#findComment-718924 Share on other sites More sharing options...
premiso Posted December 18, 2008 Share Posted December 18, 2008 Can you not use an .htaccess file to override the php.ini/httpd.conf directives? It is the actual user's browser causing the issue, not the server. Quote Link to comment https://forums.phpfreaks.com/topic/137541-uploading-files-wit-ftp_put-but-times-out/#findComment-718929 Share on other sites More sharing options...
.josh Posted December 18, 2008 Share Posted December 18, 2008 premiso: can't do that dot thing because it nothing would be output until the script was done executing anyways. He would indeed have to look into ajax/flash for that. In fact, I think that might actually be the solution: an ajax/flash preloader % loaded type script might have the side-effect of keeping your http session alive. Quote Link to comment https://forums.phpfreaks.com/topic/137541-uploading-files-wit-ftp_put-but-times-out/#findComment-718933 Share on other sites More sharing options...
premiso Posted December 18, 2008 Share Posted December 18, 2008 premiso: can't do that dot thing because it nothing would be output until the script was done executing anyways. He would indeed have to look into ajax/flash for that. In fact, I think that might actually be the solution: an ajax/flash preloader % loaded type script might have the side-effect of keeping your http session alive. Yea, I did not think so. I know it worked for me with large queries I was trying to do via php, but that is not a file upload obviously =) Quote Link to comment https://forums.phpfreaks.com/topic/137541-uploading-files-wit-ftp_put-but-times-out/#findComment-718939 Share on other sites More sharing options...
.josh Posted December 18, 2008 Share Posted December 18, 2008 umm...unless you have some php setup that somehow transcends what php normally does, I'm afraid you are mistaken. The server sends nothing to the client until after the script is done executing. If you had a really large query that returned obscene amounts of results, and echoed this obscene amount of results, it may look like it's sending it as it's coming, but that's because the browser is rendering it as it loads, not because the server is sending it 1 line at a time. Quote Link to comment https://forums.phpfreaks.com/topic/137541-uploading-files-wit-ftp_put-but-times-out/#findComment-718947 Share on other sites More sharing options...
premiso Posted December 18, 2008 Share Posted December 18, 2008 umm...unless you have some php setup that somehow transcends what php normally does, I'm afraid you are mistaken. The server sends nothing to the client until after the script is done executing. I will have to look at the code I wrote. I know it worked at one time, but you are probably right. I will see if I cannot find it and figure out what I changed to make it work. Actually I found it, I was using ob_flush and flush... <?php set_time_limit(505); $sizeTime = 500; // set size time to 500 seconds for fun $x=true; $i=0; while ($x) { echo "."; ob_flush(); flush(); sleep(30); // sleep for 30 seconds. if (($i*30) > $sizeTime) { $x = false; } $i++; } echo "<br />Finished"; ?> That seems to work for me.... EDIT: Forgot the i increment =) EDIT:EDIT: also changed the == to > due to another possible infinite loop =) EDIT:EDIT:EDIT: umm...unless you have some php setup that somehow transcends what php normally does, I'm afraid you are mistaken. The server sends nothing to the client until after the script is done executing. If you had a really large query that returned obscene amounts of results, and echoed this obscene amount of results, it may look like it's sending it as it's coming, but that's because the browser is rendering it as it loads, not because the server is sending it 1 line at a time. I would say it was more of me taking a CSV file with over 10,000 lines in it and converting it to MySQL to be entered into a new database. I wanted it done on the fly so I could just let the process run (I did not even think about using the CLI at this time) but yea that worked like a charm for me to run through that whole database and convert it from CSV to the new MySQL db version (columns different names etc). Quote Link to comment https://forums.phpfreaks.com/topic/137541-uploading-files-wit-ftp_put-but-times-out/#findComment-718956 Share on other sites More sharing options...
.josh Posted December 18, 2008 Share Posted December 18, 2008 hmm...interesting...at face value, that does indeed seem to work. I'll look into the manual entries for flush and ob_flush to see what limitations, trade-offs, etc... there are. I mean, I recognize them and know what those things are in a general sense (due to people whining about header already sent errors all the time), but I've never really looked that deeply into them, as I've never really needed to use them. Quote Link to comment https://forums.phpfreaks.com/topic/137541-uploading-files-wit-ftp_put-but-times-out/#findComment-718984 Share on other sites More sharing options...
gazfocus Posted December 18, 2008 Author Share Posted December 18, 2008 Thanks for all your help guys. I have found a couple of free flash uploaders but they seem so confusing (unless I'm being thick). The thing is, I want a form where the editor can fill in data such as 'Sermon Title', 'Speaker', 'Sermon Date', and then I need the uploader to update the MP3 file and a Notes file. Once uploaded, I then need the Sermon Title, Speaker, Sermon Date, MP3 Path, MP3 size, Notes Path and Notes file type to be stored in my MySQL database. The Flash Uploaders that I've seen are great but I can't figure out how to build them into a form and then deal with all the data as well as the code is very complicated. Can someone help? Quote Link to comment https://forums.phpfreaks.com/topic/137541-uploading-files-wit-ftp_put-but-times-out/#findComment-718998 Share on other sites More sharing options...
premiso Posted December 18, 2008 Share Posted December 18, 2008 hmm...interesting...at face value, that does indeed seem to work. I'll look into the manual entries for flush and ob_flush to see what limitations, trade-offs, etc... there are. I mean, I recognize them and know what those things are in a general sense (due to people whining about header already sent errors all the time), but I've never really looked that deeply into them, as I've never really needed to use them. lol agreed. I actually found the example in the user comments to figure that out. I never understood what the ob_'s purpose was before until I saw that and was like AHHH! =) Quote Link to comment https://forums.phpfreaks.com/topic/137541-uploading-files-wit-ftp_put-but-times-out/#findComment-719020 Share on other sites More sharing options...
gazfocus Posted December 18, 2008 Author Share Posted December 18, 2008 Thanks for all your help guys. I have found a couple of free flash uploaders but they seem so confusing (unless I'm being thick). The thing is, I want a form where the editor can fill in data such as 'Sermon Title', 'Speaker', 'Sermon Date', and then I need the uploader to update the MP3 file and a Notes file. Once uploaded, I then need the Sermon Title, Speaker, Sermon Date, MP3 Path, MP3 size, Notes Path and Notes file type to be stored in my MySQL database. The Flash Uploaders that I've seen are great but I can't figure out how to build them into a form and then deal with all the data as well as the code is very complicated. Can someone help? Quote Link to comment https://forums.phpfreaks.com/topic/137541-uploading-files-wit-ftp_put-but-times-out/#findComment-719187 Share on other sites More sharing options...
JonnoTheDev Posted December 19, 2008 Share Posted December 19, 2008 Try uber uploader. Perl CGI, kind of like ajax uploader. Used this for you-tube style video uploading http://uber-uploader.sourceforge.net/ Quote Link to comment https://forums.phpfreaks.com/topic/137541-uploading-files-wit-ftp_put-but-times-out/#findComment-719550 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.