hellonoko Posted April 6, 2009 Share Posted April 6, 2009 I am using the below simple code to copy remote files: <?php $copydir = "/home2/sharingi/public_html/scrape/scraped/"; $data = file_get_contents($url); $file = fopen($copydir . $clean_file_name, "w+"); fputs($file, $data); fclose($file); ?> However when I am attempting to copy a certain file. I run into a situation where the file does not load or error for quite some time and so the MySql code after my copy code times out. Warning: file_get_contents(http://www.theliverhearts.com/audio/02%20Local%20Lift.mp3) [function.file-get-contents]: failed to open stream: HTTP request failed! in /home2/sharingi/public_html/scrape/copy.php on line 36 MySQL server has gone away I am wondering what the best way to copy a remote file would be so that I can handle these situations and other file errors. Perhaps CURL? Quote Link to comment https://forums.phpfreaks.com/topic/152726-best-method-for-copying-remote-files/ Share on other sites More sharing options...
iarp Posted April 6, 2009 Share Posted April 6, 2009 It's telling you it can't find the file, and if the url used in the queyr there (http://www.theliverhearts.com/audio/02%20Local%20Lift.mp3). The link doesn't work to http://www.theliverhearts.com/audio/02%20Local%20Lift.mp3 Mybad, read that too fast and missed the error handling part. Quote Link to comment https://forums.phpfreaks.com/topic/152726-best-method-for-copying-remote-files/#findComment-802028 Share on other sites More sharing options...
hellonoko Posted April 6, 2009 Author Share Posted April 6, 2009 Yes I know. I am looking for a way to handle the error... Quote Link to comment https://forums.phpfreaks.com/topic/152726-best-method-for-copying-remote-files/#findComment-802030 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.