Laravel delete files from Public Folder

Laravel 24 Nov 2018

If you want to delete a file from public folder in Laravel, surely you can use PHP's unlink() method to remove that.

Besides unlink(), you can remove file by laravel way, by using the File::delete() method instead.

// 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);

Hope it will work fine. Thank you.