note 32816 deleted from function.file-put-contents by alindeman

From: Date: Fri, 25 Jul 2003 16:09:05 +0000
Subject: note 32816 deleted from function.file-put-contents by alindeman
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-52646@lists.php.net to get a copy of this message
Note Submitter: kevin@oceania.net ---- [ Editor's Note: The following can also be done using copy(). i.e.: copy('http://www.example.com/foo/bar.txt','bar.txt'); ] Here is a simple example to fetch a remote file and write it to a local file. Note: you need to have write permissions to the directory you are writing the file to. <?php // just so we know it is broken error_reporting(E_ALL); // specify a file, in this cast the php logo $url='http://static.php.net/www.php.net/images/php.gif'; // specify our local filename $filename='phplogo.gif'; // snarf the remote file $remote_file=file_get_contents($url); // write the new file if(!@file_put_contents($filename, $remote_file)){ echo "Unable to write to file $filename"; }else{ echo "Success writing to $filename"; } ?>

« previous php.notes (#52646) next »