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
afd04727
Commit
afd04727
authored
Aug 31, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #837: turn private variables into public ones.
parent
f87e4ce6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
85 deletions
+39
-85
UploadedFile.php
framework/yii/web/UploadedFile.php
+39
-85
No files found.
framework/yii/web/UploadedFile.php
View file @
afd04727
...
...
@@ -7,6 +7,7 @@
namespace
yii\web
;
use
yii\base\Object
;
use
yii\helpers\Html
;
/**
...
...
@@ -17,49 +18,42 @@ use yii\helpers\Html;
* You may also query other information about the file, including [[name]],
* [[tempName]], [[type]], [[size]] and [[error]].
*
* @property integer $error The error code. This property is read-only.
* @property boolean $hasError Whether there is an error with the uploaded file. Check [[error]] for detailed
* error code information. This property is read-only.
* @property string $name The original name of the file being uploaded. This property is read-only.
* @property integer $size The actual size of the uploaded file in bytes. This property is read-only.
* @property string $tempName The path of the uploaded file on the server. Note, this is a temporary file
* which will be automatically deleted by PHP after the current request is processed. This property is read-only.
* @property string $type The MIME-type of the uploaded file (such as "image/gif"). Since this MIME type is
* not checked on the server side, do not take this value for granted. Instead, use [[FileHelper::getMimeType()]]
* to determine the exact MIME type. This property is read-only.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
UploadedFile
extends
\yii\base\
Object
class
UploadedFile
extends
Object
{
private
static
$_files
;
private
$_name
;
private
$_tempName
;
private
$_type
;
private
$_size
;
private
$_error
;
/**
* Constructor.
* Instead of using the constructor to create a new instance,
* you should normally call [[getInstance()]] or [[getInstances()]]
* to obtain new instances.
* @param string $name the original name of the file being uploaded
* @param string $tempName the path of the uploaded file on the server.
* @param string $type the MIME-type of the uploaded file (such as "image/gif").
* @param integer $size the actual size of the uploaded file in bytes
* @param integer $error the error code
* @var string the original name of the file being uploaded
*/
public
function
__construct
(
$name
,
$tempName
,
$type
,
$size
,
$error
)
{
$this
->
_name
=
$name
;
$this
->
_tempName
=
$tempName
;
$this
->
_type
=
$type
;
$this
->
_size
=
$size
;
$this
->
_error
=
$error
;
}
public
$name
;
/**
* @var string the path of the uploaded file on the server.
* Note, this is a temporary file which will be automatically deleted by PHP
* after the current request is processed.
*/
public
$tempName
;
/**
* @var string the MIME-type of the uploaded file (such as "image/gif").
* Since this MIME type is not checked on the server side, do not take this value for granted.
* Instead, use [[FileHelper::getMimeType()]] to determine the exact MIME type.
*/
public
$type
;
/**
* @var integer the actual size of the uploaded file in bytes
*/
public
$size
;
/**
* @var integer an error code describing the status of this file uploading.
* @see http://www.php.net/manual/en/features.file-upload.errors.php
*/
public
$error
;
/**
* String output.
...
...
@@ -69,7 +63,7 @@ class UploadedFile extends \yii\base\Object
*/
public
function
__toString
()
{
return
$this
->
_
name
;
return
$this
->
name
;
}
/**
...
...
@@ -160,69 +154,23 @@ class UploadedFile extends \yii\base\Object
*/
public
function
saveAs
(
$file
,
$deleteTempFile
=
true
)
{
if
(
$this
->
_
error
==
UPLOAD_ERR_OK
)
{
if
(
$this
->
error
==
UPLOAD_ERR_OK
)
{
if
(
$deleteTempFile
)
{
return
move_uploaded_file
(
$this
->
_
tempName
,
$file
);
}
elseif
(
is_uploaded_file
(
$this
->
_
tempName
))
{
return
copy
(
$this
->
_
tempName
,
$file
);
return
move_uploaded_file
(
$this
->
tempName
,
$file
);
}
elseif
(
is_uploaded_file
(
$this
->
tempName
))
{
return
copy
(
$this
->
tempName
,
$file
);
}
}
return
false
;
}
/**
* @return string the original name of the file being uploaded
*/
public
function
getName
()
{
return
$this
->
_name
;
}
/**
* @return string the path of the uploaded file on the server.
* Note, this is a temporary file which will be automatically deleted by PHP
* after the current request is processed.
*/
public
function
getTempName
()
{
return
$this
->
_tempName
;
}
/**
* @return string the MIME-type of the uploaded file (such as "image/gif").
* Since this MIME type is not checked on the server side, do not take this value for granted.
* Instead, use [[FileHelper::getMimeType()]] to determine the exact MIME type.
*/
public
function
getType
()
{
return
$this
->
_type
;
}
/**
* @return integer the actual size of the uploaded file in bytes
*/
public
function
getSize
()
{
return
$this
->
_size
;
}
/**
* Returns an error code describing the status of this file uploading.
* @return integer the error code
* @see http://www.php.net/manual/en/features.file-upload.errors.php
*/
public
function
getError
()
{
return
$this
->
_error
;
}
/**
* @return boolean whether there is an error with the uploaded file.
* Check [[error]] for detailed error code information.
*/
public
function
getHasError
()
{
return
$this
->
_
error
!=
UPLOAD_ERR_OK
;
return
$this
->
error
!=
UPLOAD_ERR_OK
;
}
/**
...
...
@@ -258,7 +206,13 @@ class UploadedFile extends \yii\base\Object
self
::
loadFilesRecursive
(
$key
.
'['
.
$i
.
']'
,
$name
,
$tempNames
[
$i
],
$types
[
$i
],
$sizes
[
$i
],
$errors
[
$i
]);
}
}
else
{
self
::
$_files
[
$key
]
=
new
static
(
$names
,
$tempNames
,
$types
,
$sizes
,
$errors
);
self
::
$_files
[
$key
]
=
new
static
(
array
(
'name'
=>
$names
,
'tempName'
=>
$tempNames
,
'type'
=>
$types
,
'size'
=>
$sizes
,
'error'
=>
$errors
,
));
}
}
}
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