Laravel delete files from Public Folder

Laravel delete files from Public Folder

Posted on:September 25, 2017 at 03:22 PM

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