Access the answers to your technology questions today.
Subscribe Now
30-day free trial. Register in 60 seconds.
What Makes Experts Exchange Unique?
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.
Try it out and discover for yourself.
Subscribe Now
30-day free trial. Register in 60 seconds.
Join the Community
Give a Little. Get a Lot.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Join the Community
by: den4bPosted on 2007-02-28 at 16:51:24ID: 18630323
The function below lets you easily download contents of one file into another:
m/', 'google.txt');
ource)); // fix url format ) chmod($file_target, 0777); // add write permission
<?php
download('http://google.co
function download($file_source, $file_target)
{
// prepare
$file_source = str_replace(' ', '%20', html_entity_decode($file_s
if (file_exists($file_target)
// opne files
if (($rh = fopen($file_source, 'rb')) === FALSE) return false; // fopen() handles
if (($wh = fopen($file_target, 'wb')) === FALSE) return false; // error messages.
// read & write
while (!feof($rh))
{
if (fwrite($wh, fread($rh, 1024)) === FALSE)
{
// unable to write to file, possibly
// because the harddrive has filled up
fclose($rh);
fclose($wh);
return false;
}
}
// close files
fclose($rh);
fclose($wh);
return true;
}
?>