php将文本文件写入windows文件服务器
Php不是我的强项,我遇到了一个我不理解的错误。 我正在使用PHP5.2,Drupal6正在使用这些内容调用一个PHP函数 我可以成功地将文件写入运行此脚本的服务器,但无法写入需要该文件的另一个Windows(文件)服务器 以下是我的php代码:php将文本文件写入windows文件服务器,php,drupal,file-io,Php,Drupal,File Io,Php不是我的强项,我遇到了一个我不理解的错误。 我正在使用PHP5.2,Drupal6正在使用这些内容调用一个PHP函数 我可以成功地将文件写入运行此脚本的服务器,但无法写入需要该文件的另一个Windows(文件)服务器 以下是我的php代码: try{ $outputFile = "//myserver/dir1/dir2/dir_with_everybody_write_permission/print.txt"; $fh = fopen($outputFile, 'w')
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'));
}
我的错误:
[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.
为什么无法打开文件流
谢谢你的考虑
没有这样的文件或目录
我得说你写错目录了。如果你知道答案,为什么要问?是的,它无法打开该文件。可能权限不足。该目录具有“所有人”写入权限,但其中没有文件。Web服务器是否具有查看该服务器的权限?你能从中读取文件吗?是的,我已登录到web服务器并从文件服务器创建/读取文件。你的web服务器是否与你一样运行,或者它是否有自己的用户名和权限?这是一个共享和权限问题,与错误的目录差不多。