dionarap's avatar

Dealing with file storage

I am trying to store and delete files in my application but i encounter the problem of the file not going to the folder i am trying to get it into.

The folder i am trying to get it into is : 'Images/avatars/'

Unfortunately it seems to put the file into the '/images' folder and adds on 'avatars' to the file path rather than putting the image into the 'avatars' folder. So i get images file names as 'avatarsimg_1212222' rather than 'img_1212222' and the photos upload to 'images' rather than 'images/avatars/'

Where am i going wrong in my code?

       if($request->file('update-img')){
        $this->validate($request, array(
            'update-img' => 'image',
        ));
        $image = $request->file('update-img');
        $filename = uniqid('img_') . '.' . $image->getClientOriginalExtension();
        $location = public_path('images/avatars' . $filename);
        Image::make($image)->save($location);
        $user->image = $filename;

    }
0 likes
2 replies
dionarap's avatar
dionarap
OP
Best Answer
Level 1

Thanks for the help man but i've just noticed the error. The great coders fatigue and I missed out a '/' on file path :D.

Please or to participate in this conversation.