Search code examples
phpfilephp-7unlink

Deleting video files using unlink() in PHP 7


I'm facing a problem with deleting video files from folder using php unlink() function , image are deleting but when trying deleting videos it says

unlink(file_path) : permission denied.

Solution

  • You (running your script as either through CLI or a webserver) need write access to the directory in which the files are located. so access to the file is not enough.

    Your image directory would be different and writable for webserver or cli.

    chmod("your/video/dir/path",0777);
    

    try using above code before unlink the video in your script.