Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete directory using Laravel Storage Facade

I'm trying to delete a directory using Laravel Storage Facade, here's what I tried

Storage::delete('xtestx');

But unfortunately, it does not work, instead it gives me this error.

storage\app\resources\xtestx): Permission denied

any ideas, help, clues, recommendations, suggestions?

like image 1000
Juliver Galleto Avatar asked Jun 01 '16 05:06

Juliver Galleto


People also ask

How do I delete a folder in Laravel storage?

To delete a directory in the Laravel application you can make use of the "deleteDirectory()" method available from the Storage facade. <? php Storage::deleteDirectory($directory); This method will delete the directory with all of its files so you must carefully ensure that you are deleting the right directory.

How do I delete files from storage folder in Laravel 8?

You could use PHP's unlink() method just as @Khan suggested. But if you want to do it the Laravel way, use the File::delete() method instead. $files = array($file1, $file2); File::delete($files);

How do I delete files from public storage in Laravel?

For Delete files from the public folders, we can use the File::delete function into the Laravel. For use File need to use File into the controller OR We can use \File .

How do I change the default storage folder in Laravel?

By default, Laravel populates this entry in Application. php – This is hard coded to a directory relative to your applications root directory. To change this, we can modify the storage path at runtime with a service provider.


1 Answers

The method delete() is for deleting a file, to delete a directory you can use Storage::deleteDirectory('xtestx');.

like image 54
Rifki Avatar answered Sep 27 '22 23:09

Rifki