For some script i'm making, I need to copy some files "pics mainly" from a remote server to my local server.
I coded this myself with the basic knowledge I have and I'm not sure if there is a more efficient way of doing it.
$file = 'http://foo.com/bar.jpg';
$fileOut = basename($file);
$handle = fopen($file, "rb");
while (!feof($handle))
$contents .= fread($handle, 8192);
$fp = fopen($fileOut,"w" );
fwrite($fp,$contents);
fclose($fp);
What do you think? Will this suffice? Do I need to free resources or something?