Answer the question
In order to leave comments, you need to log in
Why can't I delete files from the storage folder?
public function changePhoto(Request $request){
$validator=Validator::make($request->all(),[
'image' => 'mimes:jpeg,jpg,png|required|max:10000'
]);
if($validator->fails()){
return Response::json(['error'=>$validator->errors()->all()]);
}
$file= $request->file('image')->store('uploads','public');
Storage::delete('jztPHKBy8U3WfjrKrR38OdGvda4u1PVGKuaHkA3h.jpeg');
Storage::delete('uploads/jztPHKBy8U3WfjrKrR38OdGvda4u1PVGKuaHkA3h.jpeg');
if($file){
Auth::user()->image=$file;
Auth::user()->save();
}else{
return Response::json(['success'=>FALSE]);
}
return Response::json(['success'=>TRUE,'img'=>$file ]);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question