Problem writing to a file
| From: | George Pitcher | Date: | Tue, 09 Sep 2003 14:37:54 +0000 |
| Subject: | Problem writing to a file | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-21332@lists.php.net to get a copy of this message | ||
Hi all,
I'm having a problem writing to a text file.
This is the error message:
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Warning: fwrite():
supplied argument is not a valid stream resource in
C:\Inetpub\wwwroot\packtracker\lse\pub_req_start2.php on line 276
Cannot write to file
(C:\inetpub\wwwroot\packtracker\LSE\IR201_1770.txt)
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
This is the code:
-----------------------------------------------------------------
$fp2 = "C:\\inetpub\\wwwroot\packtracker\\LSE\\".$cr.".txt";
$fp3 = "C:\\inetpub\\wwwroot\packtracker\\LSE\\".$cr.".doc";
$fn1 = file_get_contents("pub_letter.txt");
// replace some of the content placeholders with variables <<<
$content = $fn1;
if (!$fp = fopen($fp2, 'w')) {
print "Cannot open the bloody file ($fp2)";
exit;
}
// chmod($fp2,222); tried this - no effect
if (!fwrite($fp2, $content)) {
print "Cannot write to file ($fp2)";
exit;
}
rename($fp2,$fp3);
fclose($fp3);
fclose($fp2);
if($contact_route == 'Email' | $contact_route == 'email') {
----------------------------------------------------------------
So as you can see, I load a text file (actually its RTF saved as text),
parse it then write it to an open txt file, then rename that as a Word doc.
I'm running this on NT with PHP 4.3.2. The folder has write access for the
web user.
Any suggestions?
Cheers
George
===
George Pitcher
HERON Technical Manager
Ingenta plc
23-38 Hythe Bridge Street, Oxford, OX1 2ET
T +44 (0)1865 799051 direct
T +44 (0)1865 799000 switchboard
F +44 (0)1865 799134
E george.pitcher@ingenta.com
www.ingenta.com
Ingenta: Empowering the exchange of academic and professional content
online.