PHP Класс Prado\Web\UI\WebControls\TFileUpload

TFileUpload displays a file upload field on a page. Upon postback, the text entered into the field will be treated as the name of the file that will be uploaded to the server. The property {@link getHasFile HasFile} indicates whether the file upload is successful. If successful, the file may be obtained by calling {@link saveAs} to save it at a specified place. You can use {@link getFileName FileName}, {@link getFileType FileType}, {@link getFileSize FileSize} to get the original client-side file name, the file mime type, and the file size information. If the upload is not successful, {@link getErrorCode ErrorCode} contains the error code describing the cause of failure. TFileUpload raises {@link onFileUpload OnFileUpload} event if a file is uploaded (whether it succeeds or not).
С версии: 3.0
Наследование: extends TWebControl, implements Prado\Web\UI\IPostBackDataHandler, implements Prado\Web\UI\IValidatable
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_errorCode error code of the current file upload
$_localName the name of the temporary file storing the uploaded file

Открытые методы

Метод Описание
getDataChanged ( ) : boolean Returns a value indicating whether postback has caused the control data change.
getErrorCode ( ) : integer Returns an error code describing the status of this file uploading.
getFileName ( ) : string
getFileSize ( ) : integer
getFileType ( ) : string
getHasFile ( ) : boolean
getIsValid ( ) : boolean Returns true if this control validated successfully.
getLocalName ( ) : string
getMaxFileSize ( ) : integer
getValidationPropertyValue ( ) : mixed Returns the original file name as the property value to be validated.
loadPostData ( $key, $values ) : boolean Loads user input data.
onFileUpload ( $param ) This method is invoked when a file is uploaded during a postback.
onPreRender ( $param ) Sets Enctype of the form on the page.
raisePostDataChangedEvent ( ) Raises postdata changed event.
saveAs ( $fileName, $deleteTempFile = true ) : boolean Saves the uploaded file.
setIsValid ( $value )
setMaxFileSize ( $size ) Sets the maximum size that a file can be uploaded.

Защищенные методы

Метод Описание
addAttributesToRender ( $writer ) Sets name attribute to the unique ID of the control.
getTagName ( ) : string

Описание методов

addAttributesToRender() защищенный Метод

This method overrides the parent implementation with additional file update control specific attributes.
protected addAttributesToRender ( $writer )

getDataChanged() публичный Метод

This method is required by the \Prado\Web\UI\IPostBackDataHandler interface.
public getDataChanged ( ) : boolean
Результат boolean whether postback has caused the control data change. False if the page is not in postback mode.

getErrorCode() публичный Метод

Returns an error code describing the status of this file uploading.
См. также: http://www.php.net/manual/en/features.file-upload.errors.php
public getErrorCode ( ) : integer
Результат integer the error code

getFileName() публичный Метод

public getFileName ( ) : string
Результат string the original full path name of the file on the client machine

getFileSize() публичный Метод

public getFileSize ( ) : integer
Результат integer the actual size of the uploaded file in bytes

getFileType() публичный Метод

public getFileType ( ) : string
Результат string the MIME-type of the uploaded file (such as "image/gif"). This mime type is not checked on the server side and do not take its value for granted.

getHasFile() публичный Метод

public getHasFile ( ) : boolean
Результат boolean whether the file is uploaded successfully

getIsValid() публичный Метод

Defaults to true.
public getIsValid ( ) : boolean
Результат boolean wether this control validated successfully.

getLocalName() публичный Метод

public getLocalName ( ) : string
Результат string the local name of the file (where it is after being uploaded). Note, PHP will delete this file automatically after finishing this round of request.

getMaxFileSize() публичный Метод

См. также: setMaxFileSize
public getMaxFileSize ( ) : integer
Результат integer the maximum file size, defaults to 1MB (1048576 bytes).

getTagName() защищенный Метод

protected getTagName ( ) : string
Результат string tag name of the file upload control

getValidationPropertyValue() публичный Метод

This method is required by \Prado\Web\UI\IValidatable property.
public getValidationPropertyValue ( ) : mixed
Результат mixed the property value to be validated

loadPostData() публичный Метод

This method is primarly used by framework developers.
public loadPostData ( $key, $values ) : boolean
Результат boolean whether the data of the control has been changed

onFileUpload() публичный Метод

The method raises OnFileUpload event to fire up the event handler. If you override this method, be sure to call the parent implementation so that the event delegates can be invoked.
public onFileUpload ( $param )

onPreRender() публичный Метод

This method overrides the parent implementation and is invoked before render.
public onPreRender ( $param )

raisePostDataChangedEvent() публичный Метод

This method calls {@link onFileUpload} method. This method is primarly used by framework developers.

saveAs() публичный Метод

Saves the uploaded file.
public saveAs ( $fileName, $deleteTempFile = true ) : boolean
Результат boolean true if the file saving is successful

setIsValid() публичный Метод

public setIsValid ( $value )

setMaxFileSize() публичный Метод

Note, this is an advisory value to the browser. Sets this property with a reasonably large size to save users the trouble of waiting for a big file being transferred only to find that it was too big and the transfer failed.
public setMaxFileSize ( $size )

Описание свойств

$_errorCode защищенное свойство

error code of the current file upload
protected $_errorCode

$_localName защищенное свойство

the name of the temporary file storing the uploaded file
protected $_localName