PHP Class 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).
Since: 3.0
Inheritance: extends TWebControl, implements Prado\Web\UI\IPostBackDataHandler, implements Prado\Web\UI\IValidatable
Afficher le fichier Open project: pradosoft/prado Class Usage Examples

Protected Properties

Свойство Type Description
$_errorCode error code of the current file upload
$_localName the name of the temporary file storing the uploaded file

Méthodes publiques

Méthode Description
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.

Méthodes protégées

Méthode Description
addAttributesToRender ( $writer ) Sets name attribute to the unique ID of the control.
getTagName ( ) : string

Method Details

addAttributesToRender() protected méthode

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

getDataChanged() public méthode

This method is required by the \Prado\Web\UI\IPostBackDataHandler interface.
public getDataChanged ( ) : boolean
Résultat boolean whether postback has caused the control data change. False if the page is not in postback mode.

getErrorCode() public méthode

Returns an error code describing the status of this file uploading.
See also: http://www.php.net/manual/en/features.file-upload.errors.php
public getErrorCode ( ) : integer
Résultat integer the error code

getFileName() public méthode

public getFileName ( ) : string
Résultat string the original full path name of the file on the client machine

getFileSize() public méthode

public getFileSize ( ) : integer
Résultat integer the actual size of the uploaded file in bytes

getFileType() public méthode

public getFileType ( ) : string
Résultat 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 méthode

public getHasFile ( ) : boolean
Résultat boolean whether the file is uploaded successfully

getIsValid() public méthode

Defaults to true.
public getIsValid ( ) : boolean
Résultat boolean wether this control validated successfully.

getLocalName() public méthode

public getLocalName ( ) : string
Résultat 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() public méthode

See also: setMaxFileSize
public getMaxFileSize ( ) : integer
Résultat integer the maximum file size, defaults to 1MB (1048576 bytes).

getTagName() protected méthode

protected getTagName ( ) : string
Résultat string tag name of the file upload control

getValidationPropertyValue() public méthode

This method is required by \Prado\Web\UI\IValidatable property.
public getValidationPropertyValue ( ) : mixed
Résultat mixed the property value to be validated

loadPostData() public méthode

This method is primarly used by framework developers.
public loadPostData ( $key, $values ) : boolean
Résultat boolean whether the data of the control has been changed

onFileUpload() public méthode

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() public méthode

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

raisePostDataChangedEvent() public méthode

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

saveAs() public méthode

Saves the uploaded file.
public saveAs ( $fileName, $deleteTempFile = true ) : boolean
Résultat boolean true if the file saving is successful

setIsValid() public méthode

public setIsValid ( $value )

setMaxFileSize() public méthode

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 )

Property Details

$_errorCode protected_oe property

error code of the current file upload
protected $_errorCode

$_localName protected_oe property

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