How to create a folder in laravel?

by giovanny.lueilwitz , in category: PHP Frameworks , 3 months ago

How to create a folder in laravel?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by dedrick , 3 months ago

@giovanny.lueilwitz 

To create a folder in Laravel, you can use the Storage facade provided by Laravel. Here's how you can create a folder using this facade:

1
2
3
use IlluminateSupportFacadesStorage;

Storage::makeDirectory('path/to/directory');


Replace 'path/to/directory' with the path of the folder you want to create. This will create a new folder in the storage/app directory of your Laravel application.


Alternatively, you can create a folder using PHP's mkdir() function as well:

1
mkdir(storage_path('app/path/to/directory'));


This will create a folder in the storage/app directory of your Laravel application.


Remember to give proper permissions to the newly created folder so that Laravel can read and write to it.