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 ]);
}
Сервер openserver локалка