1 year ago

Path to storage folder

Posted 1 year ago by slickness

I wrote the following code. The correct path is stored in the DB but unfortunately the image is not saved in the correct storage folder. What is the right path to the storage folder? Where is the mistake?

public function updateAvatar (Request $e)

        $avatar = $e->file('avatar');
        $filename = time() . '.' . $avatar->getClientOriginalExtension();
        File::makeDirectory('public/'. Auth::id() . '/avatar/', 0777, true, true);
        $location = ('public/' . Auth::id() . '/avatar/' . $filename);
        Image::make($avatar)->resize(300, 300)->save('public/' . Auth::id() . '/avatar/' . $filename);

        $user = Auth::user();
        $user -> avatar = $location;
        $user -> update();

        return back()->with('success', lang::get('messages.avatarupdate'));

Please sign in or create an account to participate in this conversation.