Write text to a different folder
Posted: Sat Jun 11, 2005 1:18 pm
I looked all over this site and nobody seemed to need this information.
I have one folder that has open write permissions. It's the only folder I want open to writing.
But, I have a number of other pages in other folders that I would like to make a log for.
So i need to run the log script in one folder and write to another.
works fine if this file is in the open folder 'UserLog'
Does not
I also tried using the actual Path "d:\blah\blah\UserLog\write.php"
I didn't write this code BTW, I'm just learning this language.
JCART | Please use
I have one folder that has open write permissions. It's the only folder I want open to writing.
But, I have a number of other pages in other folders that I would like to make a log for.
So i need to run the log script in one folder and write to another.
Code: Select all
<?php
$data = "This is a new file entry!\n";
$file = "newfile.txt";
if (!$file_handle = fopen($file,"a")) { echo "Cannot open file"; }
if (!fwrite($file_handle, $data)) { echo "Cannot write to file"; }
echo "You have successfully written data to $file";
fclose($file_handle);
?>Code: Select all
<?php
$data = "This is a new file entry!\n";
$file = "/UserLog/newfile.txt";
if (!$file_handle = fopen($file,"a")) { echo "Cannot open file"; }
if (!fwrite($file_handle, $data)) { echo "Cannot write to file"; }
echo "You have successfully written data to $file";
fclose($file_handle);
?>I also tried using the actual Path "d:\blah\blah\UserLog\write.php"
I didn't write this code BTW, I'm just learning this language.
JCART | Please use
Code: Select all
tags when posting php code. Review [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color][/size]