What is the counterpart of:
if (!File::exists($path))
using Storage::
in Laravel 5.1 ?
Anyone?
Laravel's filesystem configuration file is located at config/filesystems.php . Within this file, you may configure all of your filesystem "disks". Each disk represents a particular storage driver and storage location.
You can use the storage_path(); function to get storage folder path.
One way to delete a file from the public directory in Laravel is to use the Storage facade. To delete a file, you will need to follow the following steps: Step 1: Check to ensure that the folder and file exist. Step 2: Delete the required file.
Now, if you need to change the directory and store into the storage folder directly, you need to change something in the filesystems. php file. 'local' => [ 'driver' => 'local', 'root' => storage_path('app'), ], Here, this line of code 'root' => storage_path('app'), responsible to define where to store.
Try this:
// To check if File exists in Laravel 5.1 $exists = Storage::disk('local')->has('file.jpg'); // To check if File exists in Laravel 5.2 $exists = Storage::disk('local')->exists('file.jpg');
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