Onyx
Onyx

Reputation: 5782

I can not create a folder and keep getting "mkdir(): No such file or directory" error in Laravel

I am simply trying to create a folder. I want to create the folder in this folder:

C:\MAMP\htdocs\LaravelProject\public\storage\uploads\albums

so in the end I want to have:

C:\MAMP\htdocs\LaravelProject\public\storage\uploads\albums\albumName

I've been trying to accomplish that using:

    public function uploadAlbum(Request $request){
        $name = $request['albumName'];
        File::makeDirectory(storage_path('public/uploads/albums/' . $name));
    }

but I keep getting the error:

"mkdir(): No such file or directory"

Upvotes: 0

Views: 1397

Answers (1)

Mahdi Younesi
Mahdi Younesi

Reputation: 7509

Use public_path() method instead

File::makeDirectory(public_path('storage/uploads/albums/'.$name));

Upvotes: 1

Related Questions