|
Class TFileUpload
TFileUpload class
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 getHasFile HasFile indicates
whether the file upload is successful. If successful, the file may be obtained
by calling TFileUpload::saveAs() to save it at a specified place. You can use getFileName FileName, getFileType FileType, 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, getErrorCode
ErrorCode contains the error code describing the cause of failure.
TFileUpload raises onFileUpload OnFileUpload event if a file is
uploaded (whether it succeeds or not).
-
TComponent
-
TApplicationComponent
-
TControl
implements
IRenderable,
IBindable
-
TWebControl
implements
IStyleable
-
TFileUpload
implements
IPostBackDataHandler,
IValidatable
Methods summary
protected
string
|
#
getTagName( )
Returns
string tag name of the file upload control
Overrides
|
protected
|
#
addAttributesToRender( THtmlWriter $writer )
Sets name attribute to the unique ID of the control. This method overrides
the parent implementation with additional file update control specific
attributes.
Sets name attribute to the unique ID of the control. This method overrides
the parent implementation with additional file update control specific
attributes.
Parameters
- $writer
THtmlWriter
the writer used for the rendering purpose
Overrides
|
public
|
#
onPreRender( mixed $param )
Sets Enctype of the form on the page. This method overrides the parent
implementation and is invoked before render.
Sets Enctype of the form on the page. This method overrides the parent
implementation and is invoked before render.
Parameters
- $param
mixed event parameter
Overrides
|
public
integer
|
#
getMaxFileSize( )
Returns
integer the maximum file size, defaults to 1MB (1048576 bytes).
See
|
public
|
#
setMaxFileSize( integer $size )
Sets the maximum size that a file can be uploaded. 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.
Sets the maximum size that a file can be uploaded. 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.
Parameters
- $size
integer the maximum upload size allowed for a file.
|
public
string
|
#
getFileName( )
Returns
string the original full path name of the file on the client machine
|
public
integer
|
#
getFileSize( )
Returns
integer the actual size of the uploaded file in bytes
|
public
string
|
#
getFileType( )
Returns
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.
|
public
string
|
#
getLocalName( )
Returns
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.
|
public
integer
|
#
getErrorCode( )
Returns an error code describing the status of this file uploading.
Returns an error code describing the status of this file uploading.
Returns
integer the error code
See
|
public
boolean
|
#
getHasFile( )
Returns
boolean whether the file is uploaded successfully
|
public
boolean
|
#
saveAs( string $fileName, boolean $deleteTempFile = true )
Saves the uploaded file.
Parameters
- $fileName
string the file name 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.
Returns
boolean true if the file saving is successful
|
public
boolean
|
#
loadPostData( string $key, array $values )
Loads user input data. This method is primarly used by framework
developers.
Loads user input data. This method is primarly used by framework
developers.
Parameters
- $key
string the key that can be used to retrieve data from the input data collection
- $values
array the input data collection
Returns
boolean whether the data of the control has been changed
Implementation of
|
public
|
#
raisePostDataChangedEvent( )
Raises postdata changed event. This method calls TFileUpload::onFileUpload() method.
This method is primarly used by framework developers.
Raises postdata changed event. This method calls TFileUpload::onFileUpload() method.
This method is primarly used by framework developers.
Implementation of
|
public
|
#
onFileUpload( TEventParameter $param )
This method is invoked when a file is uploaded during a postback. 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.
This method is invoked when a file is uploaded during a postback. 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.
Parameters
|
public
boolean
|
#
getDataChanged( )
Returns a value indicating whether postback has caused the control data
change. This method is required by the IPostBackDataHandler interface.
Returns a value indicating whether postback has caused the control data
change. This method is required by the IPostBackDataHandler interface.
Returns
boolean whether postback has caused the control data change. False if the page is not in
postback mode.
Implementation of
|
public
mixed
|
#
getValidationPropertyValue( )
Returns the original file name as the property value to be validated. This
method is required by IValidatable property.
Returns the original file name as the property value to be validated. This
method is required by IValidatable property.
Returns
mixed the property value to be validated
Implementation of
|
public
boolean
|
#
getIsValid( )
Returns true if this control validated successfully. Defaults to true.
Returns true if this control validated successfully. Defaults to true.
Returns
boolean wether this control validated successfully.
Implementation of
|
public
boolean
|
#
setIsValid( boolean $value )
Parameters
- $value
boolean wether this control is valid.
Returns
boolean wether this control's validators validated successfully
Implementation of
|
Methods inherited from TWebControl
clearStyle(),
copyBaseAttributes(),
createStyle(),
getAccessKey(),
getBackColor(),
getBorderColor(),
getBorderStyle(),
getBorderWidth(),
getCssClass(),
getDecorator(),
getDisplay(),
getEnsureId(),
getFont(),
getForeColor(),
getHasStyle(),
getHeight(),
getStyle(),
getTabIndex(),
getToolTip(),
getWidth(),
render(),
renderBeginTag(),
renderContents(),
renderEndTag(),
setAccessKey(),
setBackColor(),
setBorderColor(),
setBorderStyle(),
setBorderWidth(),
setCssClass(),
setDisplay(),
setEnsureId(),
setForeColor(),
setHeight(),
setStyle(),
setTabIndex(),
setToolTip(),
setWidth()
|
Methods inherited from TControl
__construct(),
__get(),
addParsedObject(),
addToPostDataLoader(),
addedControl(),
applyStyleSheetSkin(),
autoBindProperty(),
autoDataBindProperties(),
bindProperty(),
broadcastEvent(),
bubbleEvent(),
clearChildState(),
clearControlState(),
clearNamingContainer(),
clearViewState(),
convertUniqueIdToClientId(),
createChildControls(),
createControlCollection(),
dataBind(),
dataBindChildren(),
dataBindProperties(),
ensureChildControls(),
findControl(),
findControlsByID(),
findControlsByType(),
focus(),
getAdapter(),
getAllowChildControls(),
getAttribute(),
getAttributes(),
getChildControlsCreated(),
getClientID(),
getControlStage(),
getControlState(),
getControls(),
getCustomData(),
getEnableTheming(),
getEnableViewState(),
getEnabled(),
getHasAdapter(),
getHasAttributes(),
getHasChildInitialized(),
getHasControls(),
getHasInitialized(),
getHasLoaded(),
getHasLoadedPostData(),
getHasPreRendered(),
getID(),
getIsSkinApplied(),
getNamingContainer(),
getPage(),
getParent(),
getRegisteredObject(),
getSkinID(),
getSourceTemplateControl(),
getTemplateControl(),
getUniqueID(),
getViewState(),
getVisible(),
hasAttribute(),
initRecursive(),
isDescendentOf(),
isObjectRegistered(),
loadRecursive(),
loadState(),
loadStateRecursive(),
onDataBinding(),
onInit(),
onLoad(),
onUnload(),
preRenderRecursive(),
raiseBubbleEvent(),
registerObject(),
removeAttribute(),
removedControl(),
renderChildren(),
renderControl(),
saveState(),
saveStateRecursive(),
setAdapter(),
setAttribute(),
setChildControlsCreated(),
setControlStage(),
setControlState(),
setCustomData(),
setEnableTheming(),
setEnableViewState(),
setEnabled(),
setID(),
setPage(),
setSkinID(),
setTemplateControl(),
setViewState(),
setVisible(),
trackViewState(),
traverseChildControls(),
unbindProperty(),
unloadRecursive(),
unregisterObject()
|
Methods inherited from TComponent
__call(),
__destruct(),
__isset(),
__set(),
__sleep(),
__unset(),
__wakeup(),
asa(),
attachBehavior(),
attachBehaviors(),
attachClassBehavior(),
attachEventHandler(),
canGetProperty(),
canSetProperty(),
clearBehaviors(),
createdOnTemplate(),
detachBehavior(),
detachBehaviors(),
detachClassBehavior(),
detachEventHandler(),
disableBehavior(),
disableBehaviors(),
enableBehavior(),
enableBehaviors(),
evaluateExpression(),
evaluateStatements(),
fxAttachClassBehavior(),
fxDetachClassBehavior(),
getAutoGlobalListen(),
getBehaviorsEnabled(),
getClassHierarchy(),
getEventHandlers(),
getListeningToGlobalEvents(),
getSubProperty(),
hasEvent(),
hasEventHandler(),
hasProperty(),
isa(),
listen(),
raiseEvent(),
setSubProperty(),
unlisten()
|
Constants summary
integer |
MAX_FILE_SIZE |
1048576 |
#
Maximum file size (in bytes) allowed to be uploaded, defaults to 1MB.
Maximum file size (in bytes) allowed to be uploaded, defaults to 1MB.
|
Constants inherited from TControl
AUTOMATIC_ID_PREFIX,
CLIENT_ID_SEPARATOR,
CS_CHILD_INITIALIZED,
CS_CONSTRUCTED,
CS_INITIALIZED,
CS_LOADED,
CS_PRERENDERED,
CS_STATE_LOADED,
ID_FORMAT,
ID_SEPARATOR,
IS_CHILD_CREATED,
IS_CREATING_CHILD,
IS_DISABLE_THEMING,
IS_DISABLE_VIEWSTATE,
IS_ID_SET,
IS_SKIN_APPLIED,
IS_STYLESHEET_APPLIED,
RF_ADAPTER,
RF_AUTO_BINDINGS,
RF_CHILD_STATE,
RF_CONTROLS,
RF_CONTROLSTATE,
RF_DATA_BINDINGS,
RF_EVENTS,
RF_NAMED_CONTROLS,
RF_NAMED_CONTROLS_ID,
RF_NAMED_OBJECTS,
RF_SKIN_ID
|
Properties summary
protected
integer
|
$_errorCode |
UPLOAD_ERR_NO_FILE |
#
error code of the current file upload
error code of the current file upload
|
|