How to delete a file in laravel 4
There is still the delete method in Laravel 4:
src/Illuminate/Filesystem/Filesystem.php
otherwise just use good old unlink()
!?
Other delete usage:
// Delete a single file
File::delete($filename);
// Delete multiple files
File::delete($file1, $file2, $file3);
// Delete an array of files
$files = array($file1, $file2);
File::delete($files);
Source: http://laravel-recipes.com/recipes/133/deleting-a-file
I think you should append public_path() to file names , to get real file path, like this
File::delete(public_path().$id.'_news.jpg');
You can easily do something like:
$filename = public_path().'/uploads/foo.bar';
if (File::exists($filename)) {
File::delete($filename);
}
Reference: Laravel-recipes Delete a File