Level 122
You are saving new file to upload/teachers but deleting from upload/user ?
I am using Laravel app with Intervention Image. However, if i upload a new image, old images will not be deleted. I'm writing a controller as follows.
//user image
$image_icon = $request->file('image_icon');
if($image_icon) {
\File::delete(public_path() .'/upload/user/'.$user->image_icon.'-b.jpg');
\File::delete(public_path() .'/upload/user/big'.$user->image_icon.'-s.jpg');
$tmpFilePath = 'upload/user/';
$tmpFilePathBig = 'upload/user/big/';
$hardPath = str_slug($inputs['full_name'], '-').'-'.md5(time());
$img = Image::make($image_icon);
$img1 = Image::make($image_icon);
$img->fit(270, 225)->save($tmpFilePath.$hardPath.'-b.jpg');
$img1->fit(360, 360)->save($tmpFilePathBig.$hardPath.'-s.jpg');
$user->image_icon = $tmpFilePath.$hardPath;
}
Now i have doesn't work File::delete method. There is no file upload error. But the old image is not removed. How can i fix this problem? Thanks!
Please or to participate in this conversation.