PHP - rmdir (permission denied)

后端 未结 4 1559
挽巷
挽巷 2021-01-13 20:48

I have an easy script to create and delete a folder, but when I try to delete a folder, it brings up and error.

The code:



        
4条回答
  •  不知归路
    2021-01-13 21:22

    Generally speaking PHP scripts on Unix/Linux run as user "nobody", meaning they need the "all" privileges so it's a permissions problem with the directory. Also, to delete a file or directory in Linux/Unix you need write privileges on the parent directory. That might be your problem.

    If you have problems with the files or directories you create, use chmod() on them to set the right permissions.

    Also it might not be empty.

    Also, it's worth mentioning that

    $new_folder = $_POST['nazevS'];
    $new_dir_path = $key."/".$new_folder;
    

    is really bad from a security point of view. Sanitize that input.

提交回复
热议问题