Page 1 of 1

2am dumb question, Finding a location out of root

Posted: Fri Jan 13, 2006 1:23 am
by aybra
hello.. i know this is extremely dumb question... but using a Reactor type server on my home network, how do i point to / add lines to a file out side of the "root"??


Code: Select all

$filename = 'C:\Program Files\Sony\EverQuest II\logseq2.txt';
$somecontent = "Add this to the file\n";

// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {

   // In our example we're opening $filename in append mode.
   // The file pointer is at the bottom of the file hence 
   // that's where $somecontent will go when we fwrite() it.
   if (!$handle = fopen($filename, 'a')) {
         echo "Cannot open file ($filename)";
         exit;
   }

   // Write $somecontent to our opened file.
   if (fwrite($handle, $somecontent) === FALSE) {
       echo "Cannot write to file ($filename)";
       exit;
   }
   
   echo "Success, wrote ($somecontent) to file ($filename)";
   
   fclose($handle);

} else {
   echo "The file $filename is not writable";
}

Posted: Fri Jan 13, 2006 10:46 am
by pickle
Not entirely sure what you're asking.

Posted: Fri Jan 13, 2006 11:56 am
by aybra
sorry,

To get to a location above the directory you are working in. ../ or some form is used to get all the way up to root... but i want to go past that and go to a differant location on my hard drive... how do i get there?

Posted: Fri Jan 13, 2006 12:27 pm
by Jenk
realpath();

Posted: Fri Jan 13, 2006 12:29 pm
by aybra
Thank you!!