Reputation: 1476
Php is not my strong suit and I am getting an error I don't understand. I am using PHP 5.2 and drupal 6 is calling a php function with these contents.
I can successfully write a file to the server running this script but not to another Windows (file) server where I need the file to go.
Here is my php code:
try{
$outputFile = "//myserver/dir1/dir2/dir_with_everybody_write_permission/print.txt";
$fh = fopen($outputFile, 'w');
$filecontents = "script to be written";
fwrite($fh, $filecontents);
fclose($fh);
} catch (Exception $e) {
form_set_error('', t('File Write Error'));
}
My errors:
[function.fopen]: failed to open stream: No such file or directory in C:\web\apache\htdocs\sites\all\modules\dirA\X.module on line 161.
warning: fwrite(): supplied argument is not a valid stream resource in C:\web\apache\htdocs\sites\all\modules\dirA\X.module on line 164.
warning: fclose(): supplied argument is not a valid stream resource in C:\web\apache\htdocs\sites\all\modules\dirA\X.module on line 165.
Why is it failing to open the filestream?
thank you for your consideration.
Upvotes: 0
Views: 376
Reputation: 11467
No such file or directory
I'd say you're writing to the wrong directory.
Upvotes: 1