lckamal - 11 months ago

I am uploading a new file named "Profile.jpg" and I found that there is already a file name called "Profile.jpg". Uploader returns the previous row as upload row which is wrong data. User will see other's profile picture as theirs.

public function uploadProfilePicture(Repository $config, FileUploader $uploader, FolderRepositoryInterface $folders)
        $data = \Request::all();
        $image = \Request::file('file');

            $uploaded_image = $uploader->upload($image, $folders->findBySlug('profile_picture'));
                $profile = auth()->user()->profile();
                $profile->profile_picture_id = $uploaded_image->id;
                return response()->json(['success' => true, 'thumb' => $uploaded_image->image()->output()]);   
            return response()->json(['success' => false, 'message' => 'Porfile picture could not be uploaded.']);   

A solution is to give option on uploader to rename file name on upload. so that we can change unique name with user id or something.

any idea?

ryanthompson - 11 months ago

There's a function lying around for unique-ifying names somewhere around here. I'll see if I can dig it up.

lckamal - 11 months ago

ok please.