PHP Unlink Not working

前端 未结 7 1580
小鲜肉
小鲜肉 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 16:04

    unlink won't work with unlink('http://www.mysite.com/img1.jpg');

    use instead unlink($_SERVER['DOCUMENT_ROOT'].'img1.jpg');//takes the current directory or,

    unlink($_SERVER['DOCUMENT_ROOT'].'dir_name/img1.jpg');
    

    There may be file permission issue.please check for this.

提交回复
热议问题