7

Error : Unable to create the "http:/localhost/shopping/public/src/img/" directory

my code :
$imageName = $product->id . '.' . 
        $request->file('image')->getClientOriginalExtension();
                $request->file('image')->move(
        url().'/public/src/img/', $imageName
        );
2
  • 2
    unable to create directory which directory ? img ? Commented Feb 28, 2017 at 13:23
  • 4
    check if permission is set correctly Commented Feb 28, 2017 at 13:28

2 Answers 2

7

Use the public_path() helper, not url():

->move(public_path('src/img/'.$imageName));
Sign up to request clarification or add additional context in comments.

Comments

1

In my case issue was little bit different. I am using laravel 5.5. If i will use below code on my local system, then its work properly

$destinationPath = public_path('images\post');
$image->move($destinationPath, $inputimg);

But on production same above code throwing error. Unable to create the "/var/www/mycar/public/images\post" directory

If someone have same issue then change 'images\post' to 'images/post'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.