PHP Unlink Not working

前端 未结 7 1508
小鲜肉
小鲜肉 2021-01-11 15:34

I am trying to delete photo in php using unlink. I have used it earlier on other server but this time it is not working. I have used absolute path for a test but still does

7条回答
  •  执笔经年
    2021-01-11 15:56

    If you use unlink in a linux or unix you should also check the results of is_writable ( string $filename ) And if the function returns false, you should check the file permissions with fileperms ( string $filename ).

    File permissions are usual problems on webspaces, e.g. if you upload an file per ftp with a ftp user, and the webserver is running as an different user.

    If this is the problem, you have do to a

    chmod o+rwd img1.jpg

    or

    chmod 777 img1.jpg

    to grand write (and delete) permissions for other Users.

提交回复
热议问题