PHP Unlink Not working

前端 未结 7 1554
小鲜肉
小鲜肉 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:13

    url not allow in ulink function

    can you please used this

    It's better, also safety wise to use an absolute path. But you can get this path dynamically.

    E.g. using:

    getcwd();
    

    Depending on where your PHP script is, your variable could look like this:

    $deleteImage =  getcwd() . 'img1.jpg';
    
    unlink($deleteImage);
    

    check this

    bool unlink ( string $filename [, resource $context ] )
    

    and

    filename
    Path to the file.

    So it only takes a string as filename.

    Make sure the file is reachable with the path from the location you execute the script. This is not a problem with absolute paths, but you might have one with relative paths.

提交回复
热议问题