How to create directory in laravel?

Share Me
  •  
  •  
  •  
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share

Hi Dev’s, Now in this example, i will teach you how to create folder in laravel application. we can easily create a new directory in our  laravel application. So now we will solved simply define the command then we a create directory in laravel application. here i will teach you how to create directory in laravel.

Here we are just trying to use File::makeDirectory to create a new folder from public path.

/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index(Request $request)
{
     $file = public_path('image'); 

     $result = File::makeDirectory($file);

     dd($result);
}

It will return true if this method success, and it will return false if 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);
}

It will return true if this method success, and it will return false if this method fails.

Read Also : symlink(): No such file or directory laravel ubuntu – solved

Thanks for read. I hope it help you. For more you can follow us on facebook

About Shahriar Sagor

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Shahriar Sagor →