Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
UserAdminV2
Overview
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
庄欣
UserAdminV2
Commits
abfaeaff
Commit
abfaeaff
authored
Jun 26, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added upload_of validation rule.
parent
0b7dbab0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
0 deletions
+64
-0
system/input.php
+12
-0
system/validation/rules/upload_of.php
+52
-0
No files found.
system/input.php
View file @
abfaeaff
...
...
@@ -70,6 +70,18 @@ class Input {
}
/**
* Get an item from the uploaded file data.
*
* @param string $key
* @param mixed $default
* @return array
*/
public
static
function
file
(
$key
,
$default
=
null
)
{
return
Arr
::
get
(
$_FILES
,
$key
,
$default
);
}
/**
* Hydrate the input data for the request.
*
* @return void
...
...
system/validation/rules/upload_of.php
0 → 100644
View file @
abfaeaff
<?php
namespace
System\Validation\Rules
;
use
System\Input
;
use
System\Validation\Rule
;
class
Upload_Of
extends
Rule
{
/**
* The acceptable file extensions.
*
* @var array
*/
public
$extensions
;
/**
* The maximum file size in bytes.
*
* @var int
*/
public
$maximum
;
/**
* Evaluate the validity of an attribute.
*
* @param string $attribute
* @param array $attributes
* @return void
*/
public
function
check
(
$attribute
,
$attributes
)
{
if
(
!
array_key_exists
(
$attribute
,
Input
::
file
()))
{
return
true
;
}
$file
=
Input
::
file
(
$attribute
);
if
(
!
is_null
(
$this
->
maximum
)
and
$file
[
'size'
]
>
$this
->
maximum
)
{
return
false
;
}
if
(
!
is_null
(
$this
->
extensions
)
and
!
in_array
(
File
::
extension
(
$file
[
'name'
]),
$this
->
extensions
))
{
return
false
;
}
return
true
;
}
}
\ No newline at end of file
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