|Inheritance||yii\web\UploadedFile » yii\base\BaseObject|
|Available since version||2.0|
UploadedFile represents the information for an uploaded file.
You can call getInstance() to retrieve the instance of an uploaded file, and then use saveAs() to save it on the server. You may also query other information about the file, including $name, $tempName, $type, $size and $error.
For more details and usage information on UploadedFile, see the guide article on handling uploads.
|$error||integer||An error code describing the status of this file uploading.||yii\web\UploadedFile|
|$name||string||The original name of the file being uploaded||yii\web\UploadedFile|
|$size||integer||The actual size of the uploaded file in bytes||yii\web\UploadedFile|
|$tempName||string||The path of the uploaded file on the server.||yii\web\UploadedFile|
|$type||string||The MIME-type of the uploaded file (such as "image/gif").||yii\web\UploadedFile|
|__call()||Calls the named method which is not a class method.||yii\base\BaseObject|
|__get()||Returns the value of an object property.||yii\base\BaseObject|
|__isset()||Checks if a property is set, i.e. defined and not null.||yii\base\BaseObject|
|__set()||Sets value of an object property.||yii\base\BaseObject|
|__unset()||Sets an object property to null.||yii\base\BaseObject|
|canGetProperty()||Returns a value indicating whether a property can be read.||yii\base\BaseObject|
|canSetProperty()||Returns a value indicating whether a property can be set.||yii\base\BaseObject|
|className()||Returns the fully qualified name of this class.||yii\base\BaseObject|
|getInstance()||Returns an uploaded file for the given model attribute.||yii\web\UploadedFile|
|getInstanceByName()||Returns an uploaded file according to the given file input name.||yii\web\UploadedFile|
|getInstances()||Returns all uploaded files for the given model attribute.||yii\web\UploadedFile|
|getInstancesByName()||Returns an array of uploaded files corresponding to the specified file input name.||yii\web\UploadedFile|
|hasMethod()||Returns a value indicating whether a method is defined.||yii\base\BaseObject|
|hasProperty()||Returns a value indicating whether a property is defined.||yii\base\BaseObject|
|init()||Initializes the object.||yii\base\BaseObject|
|reset()||Cleans up the loaded UploadedFile instances.||yii\web\UploadedFile|
|saveAs()||Saves the uploaded file.||yii\web\UploadedFile|
|copyTempFile()||Copy temporary file into file specified||yii\web\UploadedFile|
An error code describing the status of this file uploading.
The original name of the file being uploaded
The actual size of the uploaded file in bytes
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.
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 yii\helpers\FileHelper::getMimeType() to determine the exact MIME type.
|public void __construct ( $config =  )|
Name-value pairs that will be used to initialize the object properties
This is PHP magic method that returns string representation of an object. The implementation here returns the uploaded file's name.
|public string __toString ( )|
The string representation of the object
Copy temporary file into file specified
|protected boolean|integer copyTempFile ( $targetFile )|
Path of the file to copy to
The total count of bytes copied, or false on failure
|public string getBaseName ( )|
Original file base name
|public string getExtension ( )|
|public boolean getHasError ( )|
Whether there is an error with the uploaded file. Check $error for detailed error code information.
Returns an uploaded file for the given model attribute.
The file should be uploaded using yii\widgets\ActiveField::fileInput().
See also getInstanceByName().
|public static null|yii\web\UploadedFile getInstance ( $model, $attribute )|
The data model
The attribute name. The attribute name may contain array indexes. For example, 'file' for tabular file uploading; and 'file' for an element in a file array.
The instance of the uploaded file. Null is returned if no file is uploaded for the specified model attribute.
Returns an uploaded file according to the given file input name.
The name can be a plain string or a string like an array element (e.g. 'Post[imageFile]', or 'Post[imageFile]').
|public static null|yii\web\UploadedFile getInstanceByName ( $name )|
The name of the file input field.
The instance of the uploaded file. Null is returned if no file is uploaded for the specified name.
Returns all uploaded files for the given model attribute.
|public static yii\web\UploadedFile getInstances ( $model, $attribute )|
The data model
The attribute name. The attribute name may contain array indexes for tabular file uploading, e.g. 'file'.
Array of UploadedFile objects. Empty array is returned if no available file was found for the given attribute.
Returns an array of uploaded files corresponding to the specified file input name.
This is mainly used when multiple files were uploaded and saved as 'files', 'files', 'files[n]'..., and you can retrieve them all by passing 'files' as the name.
|public static yii\web\UploadedFile getInstancesByName ( $name )|
The name of the array of files
The array of UploadedFile objects. Empty array is returned if no adequate upload was found. Please note that this array will contain all files from all sub-arrays regardless how deeply nested they are.
Cleans up the loaded UploadedFile instances.
This method is mainly used by test scripts to set up a fixture.
|public static void reset ( )|
Saves the uploaded file.
If the target file
$file already exists, it will be overwritten.
See also $error.
|public boolean saveAs ( $file, $deleteTempFile = true )|
The file path or a path alias used to save the uploaded file.
Whether to delete the temporary file after saving. If true, you will not be able to save the uploaded file again in the current request.
True whether the file is saved successfully