If you have problem using PHP unlink() function in CodeIgniter, I have a solution to it.
Below is the error you would most likely encounter:
A PHP Error was encountered Severity: Warning Message: unlink() [function.unlink]: http does not allow unlinking
Apparently, it seem that we can’t delete the file directly with absolute path in CodeIgniter. (Example of absolute path is http//:….)
So in order to resolve this, we have to do the following:
1 2 3 4 5 6 7 8 9 10 11 | //define the root directory of CodeIgniter $path = "images/" .$the_file_you_want_to_delete; //from here, delete the file off using unlink $result = unlink($path); if($result){ $data['status'] = "File has been deleted successfully!"; }else{ $data['status'] = "There is a problem deleting the file!"; } |
As you can see, unlinking the file using relative path works pretty fine and well.













