I can't seem to get this php code to work: <?php $file = '/home/gamesjet/public_html/test.txt'; if (is_writable($file) == false) { die('Unable to write to file'); } // The data $data = fopen("http://www.example.com/", "a+"); // Write to file file_put_contents ($file, $data); ?> PHP: i get this error: Unable to write to file test.txt is chmodded to 777.
Just a quick guess, I don't have much knowledge of this function, but shouldn't the fopen lead to /home/gamesjet/public_html/test.txt , instead of that web url?
Crayz, I believe the fopen is opening the data he wants to write into the text file. I believe. . . . who knows. . . Maybe he can be more specific. . .
all the fopen is doing is opening the connection to the website. he needs a file_get_contents in there to actually set $data before writing. as of right now all it is doing is setting $data as the file handler. http://us2.php.net/file-put-contents http://us2.php.net/file-get-contents http://us2.php.net/fopen $a = file_get_contents("http://www.foo.com"); file_put_contents("my_file.txt",$a); PHP: also file_put_contents is limited to php5 only so if using prior versions, use fopen and fwrite