Wrong array definition for extension allowed in readme.md
Closed this issue · 1 comments
urbanc commented
This is print_r example when trying to upload PNG image with "siriusphp/upload": "~1.3" in composer.json.
// not working extension config from readme.md
$uploadHandler->addRule('extension', ['allowed' => 'jpg', 'jpeg', 'png'], '{label} should be a valid image (jpg, jpeg, png)', 'Profile picture');
The problem is when trying to match if image extension .png is allowed, it is not found because allow array looks wrong:
Sirius\Validation\Rule\Upload\Extension Object
(
[options:protected] => Array
(
[allowed] => Array
(
[0] => jpg
)
[0] => Array
(
[0] => png
)
[1] => jpeg
[label] => Profile picture
)
[context:protected] =>
[messageTemplate:protected] => {label} should be a valid image (jpg, jpeg, png)
[success:protected] =>
[value:protected] =>
[errorMessagePrototype:protected] =>
)
// working extension config definition array
$uploadHandler->addRule('extension', ['allowed' => 'jpg,png,jpeg' ], '{label} should be a valid image (jpg, jpeg, png)', 'Profile picture');
How allow array looks when it's working:
Sirius\Validation\Rule\Upload\Extension Object
(
[options:protected] => Array
(
[allowed] => Array
(
[0] => jpg
[1] => png
[2] => jpeg
)
[label] => Profile picture
)
[context:protected] =>
[messageTemplate:protected] => {label} should be a valid image (jpg, jpeg, png)
[success:protected] =>
[value:protected] =>
[errorMessagePrototype:protected] =>
)
adrianmiu commented
Thanks for spotting this!