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
Datei anzeigen Open project: pradosoft/prado Class Usage Examples

Protected Properties

Property Type Description
$_errorCode error code of the current file upload
$_localName the name of the temporary file storing the uploaded file

Public Methods

Method 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.

Protected Methods

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

Method Details

addAttributesToRender() protected method

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

getDataChanged() public method

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

getErrorCode() public method

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
return integer the error code

getFileName() public method

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

getFileSize() public method

public getFileSize ( ) : integer
return integer the actual size of the uploaded file in bytes

getFileType() public method

public getFileType ( ) : string
return 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 method

public getHasFile ( ) : boolean
return boolean whether the file is uploaded successfully

getIsValid() public method

Defaults to true.
public getIsValid ( ) : boolean
return boolean wether this control validated successfully.

getLocalName() public method

public getLocalName ( ) : string
return 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 method

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

getTagName() protected method

protected getTagName ( ) : string
return string tag name of the file upload control

getValidationPropertyValue() public method

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

loadPostData() public method

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

onFileUpload() public method

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 method

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

raisePostDataChangedEvent() public method

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

saveAs() public method

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

setIsValid() public method

public setIsValid ( $value )

setMaxFileSize() public method

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