Property | Type | Description | |
---|---|---|---|
$error | an error code describing the status of this file uploading. | ||
$name | the original name of the file being uploaded | ||
$size | the actual size of the uploaded file in bytes | ||
$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. | ||
$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 [[\yii\helpers\FileHelper::getMimeType()]] to determine the exact MIME type. |
Method | Description | |
---|---|---|
__toString ( ) : string | String output. | |
getBaseName ( ) : string | ||
getExtension ( ) : string | ||
getHasError ( ) : boolean | ||
getInstance ( |
Returns an uploaded file for the given model attribute. | |
getInstanceByName ( string $name ) : null | |
Returns an uploaded file according to the given file input name. | |
getInstances ( |
Returns all uploaded files for the given model attribute. | |
getInstancesByName ( string $name ) : |
Returns an array of uploaded files corresponding to the specified file input name. | |
reset ( ) | Cleans up the loaded UploadedFile instances. | |
saveAs ( string $file, boolean $deleteTempFile = true ) : boolean | Saves the uploaded file. |
Method | Description | |
---|---|---|
loadFiles ( ) : array | Creates UploadedFile instances from $_FILE. | |
loadFilesRecursive ( string $key, mixed $names, mixed $tempNames, mixed $types, mixed $sizes, mixed $errors ) | Creates UploadedFile instances from $_FILE recursively. |
public __toString ( ) : string | ||
return | string | the string representation of the object |
public getHasError ( ) : boolean | ||
return | boolean | whether there is an error with the uploaded file. Check [[error]] for detailed error code information. |
public static getInstance ( |
||
$model | the data model | |
$attribute | string | the attribute name. The attribute name may contain array indexes. For example, '[1]file' for tabular file uploading; and 'file[1]' for an element in a file array. |
return | the instance of the uploaded file. Null is returned if no file is uploaded for the specified model attribute. |
public static getInstanceByName ( string $name ) : null | |
||
$name | string | the name of the file input field. |
return | null | |
the instance of the uploaded file. Null is returned if no file is uploaded for the specified name. |
public static getInstances ( |
||
$model | the data model | |
$attribute | string | the attribute name. The attribute name may contain array indexes for tabular file uploading, e.g. '[1]file'. |
return | array of UploadedFile objects. Empty array is returned if no available file was found for the given attribute. |
public static getInstancesByName ( string $name ) : |
||
$name | string | the name of the array of files |
return | 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. |
public static reset ( ) |
public saveAs ( string $file, boolean $deleteTempFile = true ) : boolean | ||
$file | string | the file path used to save the uploaded file |
$deleteTempFile | boolean | 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. |
return | boolean | true whether the file is saved successfully |
public $tempName |