hellonoko Posted April 8, 2009 Share Posted April 8, 2009 I have the below simple code that I use to copy remote files. It allows me to copy a file even if its larger than expected or with slower connection as I am copying mp3 and sometimes they are 100megs sometimes 4megs. However when I came across this link: this.bigstereo.net/wp-content/uploads/2009/04/stomp-yo-shoes-bloody-beetroots-remix-the-aston-shuffle-vocal-edit-1.mp3 My script basically hangs although the link is not broken and downloads perfectly. What I have noticed is that the other links load in my browser with quicktime and this link load as a Save As... dialog. Any ideas? Is there a better method I can be using to remotely copy files while still not worrying about the max_execution_time and max_file_size? Thanks. function copyFile($url,$dirname) { $url = str_replace(' ', '%20', $url); //$url = urlencode($url); @$file = fopen ($url, "rb"); if (!$file) { echo "Failed to copy $url !"; return false; } else { //copy file $filename = basename($url); $fc = fopen($dirname."$filename", "wb"); while (!feof ($file)) { $line = fread ($file, 1028); fwrite($fc,$line); } fclose($fc); //echo "File $url saved to PC!"; $time_end = microtime(true); $time = $time_end - $time_start; if ( $time > 60 ) { $time = $time / 60; echo "File: $filename coppied in $time minutes"; } else { echo "File: $filename coppied in $time seconds"; } return true; } } Link to comment https://forums.phpfreaks.com/topic/153099-copying-remote-files-with/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.