E
E
evgenin2022-02-14 19:51:28
Laravel
evgenin, 2022-02-14 19:51:28

How to properly store images in Laravel?

$user_id  = 1; // 1..... 20000
$storage_url = Storage::disk('public')->put("userfiles/$user_id", $file, 'public');


When creating the userfiles/1 folder, I get the error Impossible to create the root directory

How can I solve it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
pLavrenov, 2022-02-15
@pLavrenov

Make a check. If the folder does not exist, create it.

if(!Storage::exists($path)){
    Storage::makeDirectory($path);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question