How to Create Directory if not exists in Laravel

  205 views   3 weeks ago Laravel

In this Article, we will guide you how to create folder in storage in laravel 8 application. we are able to without difficulty create directory if now not exists the use of File or Storage facade in laravel 8 project. i can give you easy and extra solution of laravel 8 make folder in public folder or storage folder.

i'm able to come up with extra way to create folder in public folder in laravel 8. you may see i can use File facade to create folder, Storage facade will use to create directory from storage in laravel 8 and also i'm able to provide you with easy code core php to create folder.

Using File System:

public function createDirecrotory(Request $request)
    $path = public_path('upload/');

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


Using Storage System:

public function createFolder()
    $response = Storage::makeDirectory('upload/');

Using Core PHP:

public function removeFolder()
    $folderPath = public_path('uploads');
    $response = mkdir($folderPath);
Author : Harsukh Makwana
Harsukh Makwana

Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]

Related Articles