我們有一堆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