Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
f6c446ae
Commit
f6c446ae
authored
Jun 15, 2014
by
Mark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docs about file validator fixed
parent
26daa9bb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
tutorial-core-validators.md
docs/guide/tutorial-core-validators.md
+6
-3
No files found.
docs/guide/tutorial-core-validators.md
View file @
f6c446ae
...
...
@@ -231,13 +231,13 @@ either a single column or multiple columns.
[
// checks if "primaryImage" is an uploaded image file in PNG, JPG or GIF format.
// the file size must be less than 1MB
[
'primaryImage'
,
'file'
,
'
type
s'
=>
[
'png'
,
'jpg'
,
'gif'
],
'maxSize'
=>
1024
*
1024
*
1024
],
[
'primaryImage'
,
'file'
,
'
extension
s'
=>
[
'png'
,
'jpg'
,
'gif'
],
'maxSize'
=>
1024
*
1024
*
1024
],
]
```
This validator checks if the input is a valid uploaded file.
-
`
type
s`
: a list of file name extensions that are allowed to be uploaded. This can be either
-
`
extension
s`
: a list of file name extensions that are allowed to be uploaded. This can be either
an array or a string consisting of file extension names separated by space or comma (e.g. "gif, jpg").
Extension names are case-insensitive. Defaults to null, meaning all file name
extensions are allowed.
...
...
@@ -249,6 +249,9 @@ This validator checks if the input is a valid uploaded file.
-
`maxFiles`
: the maximum number of files that the given attribute can hold. Defaults to 1, meaning
the input must be a single uploaded file. If it is greater than 1, then the input must be an array
consisting of at most
`maxFiles`
number of uploaded files.
-
`checkExtensionByMimeType`
: whether to check file type (extension) with mime-type. If extension produced by
file mime-type check differs from uploaded file extension, the file will be considered as invalid. Defaults to true,
meaning perform check.
`FileValidator`
is used together with
[
[yii\web\UploadedFile
]
]. Please refer to the
[
Uploading Files
](
input-file-upload.md
)
section for complete coverage about uploading files and performing validation about the uploaded files.
...
...
@@ -286,7 +289,7 @@ back to the attribute being validated.
```
php
[
// checks if "primaryImage" is a valid image with proper size
[
'primaryImage'
,
'image'
,
'
type
s'
=>
'png, jpg'
,
[
'primaryImage'
,
'image'
,
'
extension
s'
=>
'png, jpg'
,
'minWidth'
=>
100
,
'maxWidth'
=>
1000
,
'minHeight'
=>
100
,
'maxHeight'
=>
1000
,
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment