note 32816 added to function.file-put-contents

From: Date: Sun, 08 Jun 2003 02:56:56 +0000
Subject: note 32816 added to function.file-put-contents
Groups: php.notes 
Request: Send a blank email to php-notes+get-49960@lists.php.net to get a copy of this message
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"; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.file-put-contents.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32816 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32816&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32816&report=yes

« previous php.notes (#49960) next »