Error deleting file with unlink

1

How do I remove a file with unlink?

The file is in this folder

/home/user/public_html/public/data/file.png

I'm running the unlink from this file

/home/user/public_html/admin/application/controllers/delete.php

I am using codeigniter, that is, /admin/ has a codeigniter and public_html has another

Whenever I try to remove it from this error

    
asked by anonymous 01.01.2015 / 02:28

1 answer

1

First check if the file exists using the command file_exists

The code would look something like this:

if(file_exists($caminho_para_arquivo)){
    unlink($caminho_para_arquivo);
}

More information here: link

    
02.01.2015 / 14:16