<?
define ("_MAX_DOWNLOAD_RATE", 20.5*1024); //20kb / second
function putItNow($file_source, $file_target)
{
// Preparations
$file_source = str_replace(' ', '%20', html_entity_decode($file_source)); // fix url format
if (file_exists($file_target)) { chmod($file_target, 0777); } // add write permission
// Begin transfer
if (($rh = fopen($file_source, 'rb')) === FALSE) { return false; } // fopen() handles
if (($wh = fopen($file_target, 'wb')) === FALSE) { return false; } // error messages.
while (!feof($rh))
{
// unable to write to file, possibly because the harddrive has filled up
if (fwrite($wh, fread($rh, round(_MAX_DOWNLOAD_RATE))) === FALSE) { fclose($rh); fclose($wh); return false; }
}
// Finished without errors
fflush($rh);
fflush($wh);
fclose($rh);
fclose($wh);
return true;
}
putItNow("http://www.buytemplates.net/img/display_images/thumbnails/s_blog256_01.jpg", "d:\dremi\s_blog256_01.jpg");
?>