mercredi 26 juillet 2017

Laravel: Request Ignoring Null File Input

I am trying to add a simple "required" validation rule to a file input in a form. Logically, it should fail if the no file has been inputted (and the input is thus null). However, it manages to pass without issues, because the HTTP request ignores and thus doesn't validate the file when it is null....which defeats the purpose of having a "required" rule at all.

Even stranger, the code I'm working with allows for multiple files grouped up with "name='file[]'", and even here it ignores whatever inputs are null. For example, if I have 5 file inputs and only fill in 3 of them, the resulting array in the HTTP request will only have the 3 non-null inputs, regardless of order.

So I'm aware of what the issue is, but not really how to resolve it. Does anyone know how to force Laravel to recognize and thus validate null file inputs?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire