Laravel Create Folder If Not Exists Example
hi guys,
In this example, i will show you create folder in laravel. we can easily create directory in laravel. we can solved simply define the command then create directory if not exists in laravel.
you are just trying to use File::makeDirectory to create folder from public path.
solution for laravel
/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index(Request $request)
{
$path = public_path('upload/');
if(!File::isDirectory($path)){
File::makeDirectory($path, 0777, true, true);
// retry storing the file in the newly created path.
}
}
If return true this method success, return false this method fails.
solution for php
/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index(Request $request)
{
$file = public_path('images');
$result = mkdir($file);
dd($result);
}
If return true this method success, return false this method fails.
It will help you...
- How to Notifications With database Driver in Laravel 11?
- How to Send Email Via Notification in Laravel 11?
- How to Install and Configure Laravel 11 Debugbar?
- How to Like Dislike System in Laravel 11?
- How to Paginate a Model with Relationship in Laravel 11?
- Laravel 11 Upload Files to Amazon S3 Example
- Laravel 11 Send WhatsApp Messages Example
- Laravel 11 Rest API Authentication Using JWT Tutorial