0
嗨我使用fopen
php函數來維護日誌。我可以在我自己的電腦中寫入文件。但是如何讓PHP能夠通過本地網絡寫文件。網絡中的其他計算機通過IP訪問我的計算機PHP應用程序,但在寫入日誌文件時未通過權限。我的代碼是:使用PHP通過本地網絡進行文件處理
function hotellog($txt) {
date_default_timezone_set("Asia/Kathmandu");
$newfile = '\\localhost\gandaki/wp-content/hotel_log.json';
if (file_exists($newfile)) {
$myfile = fopen($newfile, "a") or die("Unable to open file!");
$txt = date("Y-m-d h:i:s") . "\r\t\t" . $txt . "\n\n\n";
fwrite($myfile, $txt);
fclose($myfile);
} else {
$myfile = fopen($newfile, 'w') or die("Can't create file");
$txt = date("Y-m-d h:i:s") . "\r\t\t" . $txt . "\n\n\n";
fwrite($myfile, $txt);
fclose($myfile);
}
}
網絡上的其他計算機會因'權限被拒絕'而出現錯誤。
假設你不使用'localhost'?然後正確設置權限。 –
我已經從文件系統讀取了寫入權限,但是它的權限被拒絕。 – user254153
並分享權限?對於特定的用戶帳戶? –