Are u using the same name for the new image? Maybe it's your browser cache. Try CTRL F5.
Oct 6, 2016
6
Level 5
Why you cache like this?
Hi everyone
So i've just made a simple image upload for my website but i have a problem
laravel is caching the original image.
here's my code so far as you can see if the file exists it deletes it and adds the new one uploaded but the old one displays? I have tried using cache::flush(); but that did nothing, I checked the image on the mounted drive to my website and the new one IS there.
how can i get it to reset the cache if it its replacing the file?
public function upload(Request $request){
$id = Auth::user()->id;
$path = public_path().'/img/members/'.$id;
if (!file_exists($path)) {
File::makeDirectory($path, $mode = 0777, true, true);
}
if (file_exists($path.'/profile_pic.jpg')) {
File::delete($path.'/profile_pic.jpg');
}
if($request->hasFile('profile_pic')) {
$file = Input::file('profile_pic');
$file->move($path.'/', 'profile_pic.jpg');
} else {
return Redirect()->back()->with('error','this is not a valid type');
}
return Redirect()->back();
}
}
Level 3
Please or to participate in this conversation.