[英]PHP Created file | SSH Can't delete (permission denied)
Linux SSH
我使用 php 創建一個文件
if (!is_dir(DIR_FILE))
mkdir(DIR_FILE, 0777);
$filename = DIR_FILE . $id . '.txt';
$handle_cf = fopen($filename, 'a');
fwrite($handle_cf, $data . "\n");
fclose($handle_cf);
chmod($filename, 0777);
chown($filename, "usr111"); // usr111 = username
chgrp($filename, "usr111"); // usr111 = group that is also attached to apache
該文件獲得以下權限。
-rwxrwxrwx 1 apache apache 1447 Apr 4 12:48 D.txt
-rwxrwxrwx 1 apache apache 1447 Apr 4 12:48 E.txt
但是,當我嘗試刪除該文件時,在普通用戶帳戶 (usr111) 下。 我收到以下錯誤
[usr111@host session]$ rm D.txt
rm: cannot remove `D.txt': Permission denied
注意:我可以刪除根目錄下的文件。
找到修復。 即使我在 mkdir 上使用 php 的模式設置。出於某種原因,這不起作用。 我添加了以下內容。
if (!is_dir($dir)) {
mkdir($dir, 0777);
chmod($dir, 0777);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.