unlink cannot delete file

前端 未结 2 1167
死守一世寂寞
死守一世寂寞 2021-01-19 07:26

I\'m frustrated about deleting file in ubuntu using PHP unlink().

I created a very simple simulation as follow:

  1. create a folder named \"files\" beneath
相关标签:
2条回答
  • 2021-01-19 08:22

    Unlink throws a warning on failure. Check if E_WARNING is visible for you to find out whats going on.

    It usually boils down to user rights. Keep in mind if your script is executed by a browser, usually a user named wwwrun or wwwdata (or something similar) is executing it on your server.

    Check if this user has permissions to delete, then try again.

    0 讨论(0)
  • 2021-01-19 08:29

    The folder/owner of the directory could be a different user than the user being used to run php.

    You should create a folder with the user php assigned. If you cannot do that yourself ask your ISP to do it. That is how I solved a similar problem.

    One user cannot delete files of another user on a unix system. If you would set it to 777 then you could delete it...

    0 讨论(0)
提交回复
热议问题