HEEEELP! CAN'T WRITE ON A FILE

From: Date: Tue, 28 Jan 2003 19:46:01 +0000
Subject: HEEEELP! CAN'T WRITE ON A FILE
Groups: php.windows 
Request: Send a blank email to php-windows+get-18147@lists.php.net to get a copy of this message
Hello ! I'm in a mess. Please help me. Every time I tried to write with fwrite or fputs in a file, I get an error on windows nt sp6 , ie6 from "Doc. Watson" saying that Apache.exe makes an application access error . Filesystem functions: is_readable, is_writable,fopen,fclose are ok . I can create, find and open the file. versions: PHP 4.2.3, APACHE 1.3 httpd.conf : Alias /test/ "C:/Apache/htdocs/test/" <Directory "C:/Apache/htdocs/test"> Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all </Directory> ---------- example1: // start buffering the output ob_start(); $filename = "c:\\apache\\htdocs\\test\files\\mifile.txt"; // output format - either "www" or "file" $output = "file"; // print some output print "Welcome to the Matrix, Neo"; // now decide what to do with the buffered output if ($output == "www") { // either print the contents of the buffer... ob_end_flush(); } else { // ... or write it to a file $data = ob_get_contents(); chmod ($filename, 0777); $fp = fopen ($filename, "wb+"); //ERROR IS HERE fwrite($fp, $data); fclose($fp); ob_end_clean(); } example 2: //I've tried each of the following 5 $filename assignments. //$filename = "c:\\apache\\htdocs\\mcm\\mifile.txt"; //$filename = "/mifile.txt"; //$filename = "mifile.txt"; //$filename = "c:\\tmp\\mifile.txt"; $filename = "c:\\apache\\htdocs\\test\files\\mifile.txt"; $somecontent = "Add this to the file\n"; $fp = fopen($filename,"wb"); // Write $somecontent to our opened file. //ERROR IS HERE if (!fwrite($fp, $somecontent)) { print "Cannot write to file ($filename)"; exit; } fclose($fp);

« previous php.windows (#18147) next »