Closed danFWD closed 1 year ago
EDIT: Scratch the last part about the required rule not working. After review, it does actually work.
@danFWD Thanks for reporting this issue.
The error you are seeing happens because the _FILES array is not being converted to a normalised array format. That only happens when dot notation is used. Examples for handling multiple file uploads is documented in the current readme, however: there is no explicit warning about requiring the use of dot notation on the attribute name.
I will update the docs accordingly and add an exception in the file validation trait to guard against this scenario.
1.4.2 will now raise an exception if the file data appears as an array and the docs have been revised to make it clear that dot notation is needed.
When using a file input with the 'multiple' attribute, you must add a validation rule with the dot syntax e.g.
photos.*
or it throws an error if one or more files is attached:I assume this is expected behavior, but the uncaught error should probably return an exception.
In addition, when requiring a file to be attached to a multiple-file input, it does not throw a validation error if no file is attached:<input type="file" name="photos" multiple accept=".jpg,.jpeg" />
Am I interpreting or writing the rule wrong, or am I correct in that this is a bug?