Jan 10, 2018
0
Level 10
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.
Please or to participate in this conversation.