mardi 28 avril 2020

error 403 forbidden, when I upload image in laravel 5.8

I testing a code for upload image on laravel 5.8 local and I uploaded image unsuccessful then I recieved error 403 forbidden.

public function store(Request $request)
    {
       request()->validate([
            'profile_image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
       ]);
       if ($files = $request->file('profile_image')) {
        // Define upload path
           $destinationPath = public_path('/profile_images/'); // upload path
        // Upload Orginal Image           
           $profileImage = date('YmdHis') . "." . $files->getClientOriginalExtension();
           $files->move($destinationPath, $profileImage);

           $insert['image'] = "$profileImage";
        // Save In Database
            $imagemodel= new Photo();
            $imagemodel->photo_name="$profileImage";
            $imagemodel->save();
        }
        return back()->with('success', 'Image Upload successfully');

    }

error 403 forbidden after I uploaded image and now I can't back to a normal I followed above code on internet and I don't know where I wrong. I need help ! Thank you.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire