我们有一堆linuix和windows服务器。使用PHP将文件写入Windows Server的Linux操作系统Web共享
在我的Windows桌面上,我可以看到所有的份额。
使用PHP我试图使用UNC路径将文件写入Windows共享上的目录。
//ServerShare/directory/file.txt
使用fwrite
表示它成功写入文件,但文件从不在服务器上存在。
使用opendir
函数说目录不可访问。
这是源代码非常简单。
$file_name = "\\SERVER2\Share\CPI\data.txt";
if (!$handle = fopen($file_name, 'w')) {
echo "Cannot open file ($file_name)";
exit;
}
// Write $somecontent to our opened file.
$somecontent = "this is a test";
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote ($somecontent) to file ($file_name)";
fclose($handle);
想知道需要设置什么类型的权限才能让Linux机器将文件写入Windows机箱?
fyi,$ file_name是这样的 $ file_name =“\\\\ SERVER2 \\ Share \\ CPI_INFO \\ data.txt”; – 2012-08-15 14:26:59