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?
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.
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);
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 .
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.
The method delete()
is for deleting a file, to delete a directory you can use Storage::deleteDirectory('xtestx');
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With