mkdir(): Permission denied Laravel

Try:

sudo chown -R www-data:www-data /var/www/yoursite/public

You are trying to move the uploaded file a folder in the root of your server. Make sure you get the absolute path right.

$logicpath = public_path() . '/userdp/' . $user_id . '/';

I have found a very interesting solution to this problem. Just put "." sign like this example. It works for me.

$destinationPath = "./public/uploads"; // upload path
    if (!file_exists($destinationPath)) {
      mkdir($destinationPath, 0755, true);
    }
    $request->sub_category_attr_value->move($destinationPath, $picName);

Tags:

Php

Laravel