cObject
---cWebBaseObject
------cWebObject
---------cWebBaseUIObject
------------cWebBaseDEOServer
---------------cWebBaseControl
------------------cWebBaseFileUpload
---------------------cWebFileUploadButton
The file upload button is a special button that shows a file selection dialog when clicked. Once files are selected, it will start uploading the file(s).
The developer only has to provide the path where the files should be stored on the server by implementing the OnFileUpload event.
Object oFileUpload is a cWebFileUploadButton
Set piColumnSpan to 3
Set psCaption to "Upload File(s)"
Function OnFileUpload String sFileName Integer iBytes String sMime Returns String
String sPath
// Determine local path based on workspace setting
Get psDataPath of (phoWorkspace(ghoApplication)) to sPath
Move (sPath + "\Uploads\" + sFileName) to sPath
Function_Return sPath
End_Function
End_Object
A progress dialog will be shown that, dpending on browser support, will even show the exact upload progress on a progress bar.
For security reasons, the upload folder needs to be registered as an accessible upload folder for every process using RegisterUploadFolder.
If you want to hide this button (pbVisible) and trigger the upload from another control (for example, a cWebImage), you can use ClientAction to do so:
Object oPreview is a cWebImage
Set pbFillHeight to True
Set pePosition to wiCenter
Set pbScroll to True
Set pbShowBorder to True
Set psUrl to "Images/PoweredByDataFlex.png"
Procedure OnClick
Send ClientAction of oFileUploadButton1 "selectFiles"
End_Procedure
End_Object
Modern browser support files to be dropped onto the browser window. The cWebFileUploadButton and cWebFileUploadForm controls both support this and the drop zone is configurable using the phoDropZone property. It defaults to the control itself, but it can be set to panels, views or even the entire web app to extend the drop zone.
This control can be used as a valid drop target by registering it as such in a cWebDragDropHelper object.
The supported actions for this control are:
- C_WebDropOnControl
This allows the control to accept data dragged from elsewhere in the control (if configured that way) and can also be used to accept files when registered within a cWebDragDropFileHelper.