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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
64deaad7
Commit
64deaad7
authored
Jun 14, 2014
by
Mark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
undo changes
parent
52283616
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
33 deletions
+3
-33
FileValidator.php
framework/validators/FileValidator.php
+3
-33
No files found.
framework/validators/FileValidator.php
View file @
64deaad7
...
...
@@ -206,13 +206,13 @@ class FileValidator extends Validator
switch
(
$file
->
error
)
{
case
UPLOAD_ERR_OK
:
if
(
$this
->
maxSize
!==
null
&&
!
$this
->
validateMaxSize
(
$file
)
)
{
if
(
$this
->
maxSize
!==
null
&&
$file
->
size
>
$this
->
maxSize
)
{
return
[
$this
->
tooBig
,
[
'file'
=>
$file
->
name
,
'limit'
=>
$this
->
getSizeLimit
()]];
}
elseif
(
$this
->
minSize
!==
null
&&
!
$this
->
validateMinSize
(
$file
)
)
{
}
elseif
(
$this
->
minSize
!==
null
&&
$file
->
size
<
$this
->
minSize
)
{
return
[
$this
->
tooSmall
,
[
'file'
=>
$file
->
name
,
'limit'
=>
$this
->
minSize
]];
}
elseif
(
!
empty
(
$this
->
types
)
&&
!
$this
->
validateType
(
$file
))
{
return
[
$this
->
wrongType
,
[
'file'
=>
$file
->
name
,
'extensions'
=>
implode
(
', '
,
$this
->
types
)]];
}
elseif
(
!
empty
(
$this
->
mimeTypes
)
&&
!
$this
->
validateMimeType
(
$fil
e
))
{
}
elseif
(
!
empty
(
$this
->
mimeTypes
)
&&
!
in_array
(
FileHelper
::
getMimeType
(
$file
->
tempName
),
$this
->
mimeTypes
,
tru
e
))
{
return
[
$this
->
wrongMimeType
,
[
'file'
=>
$file
->
name
,
'mimeTypes'
=>
implode
(
', '
,
$this
->
mimeTypes
)]];
}
else
{
return
null
;
...
...
@@ -318,34 +318,4 @@ class FileValidator extends Validator
return
true
;
}
/**
* Checks if given uploaded file have correct mime-type.
* @param \yii\web\UploadedFile $file
* @return boolean
*/
public
function
validateMimeType
(
$file
)
{
return
in_array
(
FileHelper
::
getMimeType
(
$file
->
tempName
),
$this
->
mimeTypes
,
true
);
}
/**
* Checks if given uploaded file have correct size according current max size.
* @param \yii\web\UploadedFile $file
* @return boolean
*/
public
function
validateMaxSize
(
$file
)
{
return
$this
->
maxSize
>
$file
->
size
;
}
/**
* Checks if given uploaded file have correct size according current min size.
* @param \yii\web\UploadedFile $file
* @return boolean
*/
public
function
validateMinSize
(
$file
)
{
return
$this
->
minSize
<
$file
->
size
;
}
}
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