O
O
ortsuev332019-10-12 11:14:03
Laravel
ortsuev33, 2019-10-12 11:14:03

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 ]);
           }

server openserver locale

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
ortsuev33, 2019-10-13
@ortsuev33

Decision ..Storage::disk('public')->delete($imgpath);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question