Yii2 - 文件验证器的 minSize 和 maxSize 适用于多少个文件?
Yii2 - minSize and maxSize of the file validator apply to how many files?
根据Core Validators指南,minSize
和maxSize
被描述为
the minimum/maximum number of bytes required for the uploaded file.
但是没有说明这些属性适用于多少个文件。
是每个文件还是所有文件的总大小?
在验证器代码中,它检查方法 validateValue()
中的大小,因此每个文件的大小为 min/max,而不是所有文件。
来自line 207:
foreach ($files as $file) {
$result = $this->validateValue($file);
...
错误示例:
[
"The file \"git-flow cheatsheet.png\" is too big. Its size cannot exceed 819.2 KiB.",
"The file \"IMG_20170531_134929.jpg\" is too big. Its size cannot exceed 819.2 KiB.",
"The file \"Lenovo sound recorder icon.jpg\" is too small. Its size cannot be smaller than 409.6 KiB.",
"The file \"memorable-linux-milestone_502911b05dc45.jpg\" is too small. Its size cannot be smaller than 409.6 KiB."
]
根据Core Validators指南,minSize
和maxSize
被描述为
the minimum/maximum number of bytes required for the uploaded file.
但是没有说明这些属性适用于多少个文件。
是每个文件还是所有文件的总大小?
在验证器代码中,它检查方法 validateValue()
中的大小,因此每个文件的大小为 min/max,而不是所有文件。
来自line 207:
foreach ($files as $file) {
$result = $this->validateValue($file);
...
错误示例:
[
"The file \"git-flow cheatsheet.png\" is too big. Its size cannot exceed 819.2 KiB.",
"The file \"IMG_20170531_134929.jpg\" is too big. Its size cannot exceed 819.2 KiB.",
"The file \"Lenovo sound recorder icon.jpg\" is too small. Its size cannot be smaller than 409.6 KiB.",
"The file \"memorable-linux-milestone_502911b05dc45.jpg\" is too small. Its size cannot be smaller than 409.6 KiB."
]