LaraBABA's avatar

uploading image via API

Hello,

I would like to know what is the best way to send images from my Android to the Laravel 5.5 API. I am using the passport feature.

Currently this is my code:

    public function store(Request $request)
    {

        $validator = Validator::make($request->all(), [
            'description' => 'required|string|min:2|max:750',
            'latitude' => 'required|string|min:2|max:64',
            'longitude' => 'required|string|min:2|max:64',
            'siteimage' => 'required|image|mimes:jpeg,bmp,png,jpg|max:20480'
        ],
            $messages = [
                'siteimage.required' => 'You must upload an image!',
                'siteimage.max' => 'Sorry but we do not allow images bigger than 20MB!',
            ]);


        if ($validator->fails()) {
            return response()->json($validator->messages(), 400);
        } else {

Thank you.

0 likes
0 replies

Please or to participate in this conversation.