roemer
1409
6
Requests

Image validation fails with SVG

Posted 2 years ago by roemer

Hi everyone,

A client of mine complained today that one of his customers can't upload their SVG logo into an App. I found this odd since I validate for image and the documentation clearly states:

The file under validation must be an image (jpeg, png, bmp, gif, or svg)

Still, the request was denied. The validation message for an invalid image shows up as the response for the request (REST API). In short, here's my code:

$validator = Validator::make($request->all(), [
    'logo' => 'required|image|max:20000'
]);

I've also tried it like this, but that doesn't work either, same message.

$validator = Validator::make($request->all(), [
    'logo' => 'required|mimes:jpg,jpeg,png,gif,svg|max:20000'
]);

Can anyone spot what's going wrong? Thanks!

Please sign in or create an account to participate in this conversation.