Upload images laravel in shared hosting

I have successfully deployed my laravel application on a shared server. When i run code on localhost everything is okay. Everything looks great except the fact that I am unable to upload the images that are being uploaded to the/public_html/img/avatars/.

```
 //this is how i store my images
...
 if ($request->hasFile('avatar'))
        {
            $user = User::find(Auth::user()->id);
            $avatar = $request->file('avatar'); // in here 
            $filename = time() . '.' . $avatar->getClientOriginalName();
            $path = 'img/avatars';
            $avatar->move($path, $filename);
            $user->avatar = $filename;  
            $user->save();
              
        }
 // this is my filesystems.php config
...
 'public' => [
          'driver' => 'local',
          'root' => public_path('app/public_html/'),
          'url' => env('APP_URL').'/storage',
          'visibility' => 'public',
        ],
...

Any idea to solve this problem? Thank you.

This might be a controversial solution, but try changing /avatars permissions to 775, if that doesn’t work, try 777 (you can do this from the File Manager or an FTP client).

This topic was automatically closed after 3 days. New replies are no longer allowed.