Laravel Create Directory If Doesn’t Exists Example

In this example, you learn laravel create directory if doesn’t exists, how to create folder in storage in laravel, Create folder if does not exists in laravel.

isDirectory() function check if directory exists in laravel application. makeDirectory() function is create directory in laravel application. We will show how to create folder in public folder when folder does not exists.

Create directory if doesn’t exists in laravel


namespace App\Http\Controllers;

use Illuminate\Http\Request;
use File;

class UserController extends Controller
    public function index(){
        $path = public_path('upload/webtuts');

            File::makeDirectory($path, 0777, true, true);

I hope you understand of create directory if doesn’t exists in laravel and it can help you…

Read Also :  Laravel has Many Through Relationship Example