phpnewbie8 Posted January 23, 2009 Share Posted January 23, 2009 I'm having a problem getting the copy function to work on my website. I am copying video files from youtube to my server. If I choose a short video, about 3 mins or less, everything works fine. If I choose a longer video, the copying goes for a few seconds, but then I get a 500 Internal Server Error. The file is visible on my server, but it seems to only copy about 5mb or so then gives up. I am using dreamhost and I have unlimited disk space and bandwidth. Does anyone know of a way to increase the copy capacity for larger files? $final = "video link"; // this isn't the actual link just for the example code $ext = "_video.flv"; $file_name = $video_id.$ext; $location= "/mydomain.com/flv_files"; if (!copy($final, "$location/$file_name")) { echo "failed to copy $final to $location.$file_name...\n"; } Quote Link to comment Share on other sites More sharing options...
redarrow Posted January 23, 2009 Share Posted January 23, 2009 show us the full code that get the video and copy's it then m8 Quote Link to comment Share on other sites More sharing options...
premiso Posted January 23, 2009 Share Posted January 23, 2009 You need to check your memory_limit and your time_limit. set_time_limit will help you to remove the max execution time, then the ini_set method to set the max_memory_usage or something along those lines. Although it should be defaulted to 16MB. You may do a phpinfo and check what the memory limit is being set at, as dreamhost may set it to be 5MB. Quote Link to comment Share on other sites More sharing options...
phpnewbie8 Posted January 23, 2009 Author Share Posted January 23, 2009 You need to check your memory_limit and your time_limit. set_time_limit will help you to remove the max execution time, then the ini_set method to set the max_memory_usage or something along those lines. Although it should be defaulted to 16MB. You may do a phpinfo and check what the memory limit is being set at, as dreamhost may set it to be 5MB. Thanks for the help. I checked the phpinfo and I think I'm ok with the memory limit (16mb). But my max_execution_time is 30 secs. I did a test and my script seemed to last ~ 40 secs so I bet that's the problem. Should I change the time limit in the code itself, or in a configuration file? I have read about php.ini files but I don't know that much about it. Quote Link to comment Share on other sites More sharing options...
premiso Posted January 23, 2009 Share Posted January 23, 2009 You need to check your memory_limit and your time_limit. set_time_limit will help you to remove the max execution time, then the ini_set method to set the max_memory_usage or something along those lines. Although it should be defaulted to 16MB. You may do a phpinfo and check what the memory limit is being set at, as dreamhost may set it to be 5MB. Thanks for the help. I checked the phpinfo and I think I'm ok with the memory limit (16mb). But my max_execution_time is 30 secs. I did a test and my script seemed to last ~ 40 secs so I bet that's the problem. Should I change the time limit in the code itself, or in a configuration file? I have read about php.ini files but I don't know that much about it. The script itself is fine. Quote Link to comment Share on other sites More sharing options...
phpnewbie8 Posted January 23, 2009 Author Share Posted January 23, 2009 The script itself is fine. Thanks again. I was able to change the max execution time using "set_time_limit." Unfortunately though I am still getting the internal server error after about 30-40 secs. I copied some other data from phpinfo() that might be related: Local/Master max_input_time 60 60 memory_limit 90M 90M post_max_size 8M 8M max_execution_time 600 30 upload_max_filesize 7M 7M I tried changing some of the other values but just using the same name didn't seem to work, like max_input_time(300). Could some of these other values be stopping the script? I wasn't sure of copying the file would fall under the upload_max_filesize? Quote Link to comment Share on other sites More sharing options...
haku Posted January 23, 2009 Share Posted January 23, 2009 As a side point, you may want to be careful with this, as it is very possible that downloading youtube videos onto your site and displaying them (if that is what you intend to do) is probably illegal on some level. You should read their user agreement carefully before doing this. Although if you are just downloading them for personal use, not to be shown to the public, you are probably ok. Quote Link to comment Share on other sites More sharing options...
phpnewbie8 Posted January 23, 2009 Author Share Posted January 23, 2009 As a side point, you may want to be careful with this, as it is very possible that downloading youtube videos onto your site and displaying them (if that is what you intend to do) is probably illegal on some level. You should read their user agreement carefully before doing this. Although if you are just downloading them for personal use, not to be shown to the public, you are probably ok. Thanks for the heads up. My site right now just gives the requested flv file to download, which is easy enough because they download it directly from youtube. I was trying this out to see if I could get the flv file on my server, then convert it to a more common file type (avi, mpeg). This is probably against their terms though. I think I have been able to solve my download limit issue, it seems to be working now. If anyone else has dreamhost or a similar problem I followed the instructions on this site: http://www.activecollab.com/forums/topic/1507/ 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.