Home >> Snippet List >> Snippet

Name
Copy a remote file to your site
Description
Copies any file (image, zip, swf, etc) from a remote site to a file on your site
PHP Snippet
FUNCTION copy_file($url,$filename){
 
	$file = FOPEN ($url, "rb");
 
	IF (!$file) RETURN FALSE; ELSE {
		$fc = FOPEN($filename, "wb");
 
		WHILE (!FEOF ($file)) {
			$line = FREAD ($file, 1028);
			FWRITE($fc,$line);
		}
 
		FCLOSE($fc);
		RETURN TRUE;
	}
}