Level 33
Hi, what kind of response are you getting?
Hello,
Could someone please tell me why my validation does not work? I am receiving the image in base64, I tried to decoded it and repass it through the validator by remerging the image in the request.
public function store(Request $request)
{
$encodedImage = $request->get('siteimage');
$decodedImage = base64_decode($encodedImage);
$request->merge(['siteimage' => $decodedImage]);
$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,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);
Thanks in advance.
Please or to participate in this conversation.