TWebFilePicker
Description
The file picker component allows to pick files from the local file system.
HTML template tag
The HTML tag the component can be associated with in an HTML template. Assign the ID
attribute with a unique value and set the identical value to the ElementID
property. Detailed
information can be found in the Use of HTML templates topic.
HTML tag | <INPUT TYPE=”FILE” ID=”UniqueID”> |
---|---|
ElementID | UniqueID |
Properties for TWebFilePicker
Property | Description |
---|---|
Accept | Sets an optional file filter. This is a string containing the extensions of files that can be selected. Note that setting the file filter will not prevent that the user can pick other filenames. To select only text files (*.txt) , set Accept to ‘.txt’ . To select JPEG , GIF , PNG image files , set Accept to ‘.jpg,.jpeg,.png,.gif’ or it could also be set to: ‘image/*’ . |
Files | This is a list of files picked. The list consists of objects of the TFile type. |
Multifile | When true, it is allowed to pick or drag multiple files. |
Events for TWebFilePicker
Property | Description |
---|---|
OnChange | Event triggered when the file(s) picked changed by the user. |
OnGetFileAsArrayBuffer | Event triggered when the the retrieval or a file as an array buffer is completed. Retrieval of the file is done programmatically by calling WebFilePicker.Files[index].GetFileAsArrayBuffer |
OnGetFileAsText | Event triggered when the the retrieval or a file as text is completed. Retrieval of the file is done programmatically by calling WebFilePicker.Files[index].GetFileAsText |
OnGetFileAsBase64 | Event triggered when the the retrieval or a file as base64 encode text is completed. Retrieval of the file is done programmatically by calling WebFilePicker.Files[index].GetFileAsBase64 |
OnGetFileAsDataURL | Event triggered when the the retrieval or a file as Data URL is completed. Retrieval of the file is done programmatically by calling WebFileUpload.Files[index].GetFileAsDataURL |
OnUploadFileComplete | Event triggered when an upload of the file is completed. The upload is started with WebFileUpload.Files[index].Upload(AAction); |
OnUploadFileResponseComplete | Event triggered when an upload of the file is completed. The upload is started with WebFileUpload.Files[index].Upload(AAction); This event returns the JavaScript request object as well as response as text |
OnUploadFileAbort | Event triggered when an upload of the file is aborted |
OnUploadFileError | Event triggered when an error has occurred during a file upload |
OnUploadFileProgress | Event triggered to indicate the progress of an upload transfer. The event returns the number of bytes transferred from the total number of bytes to transfer |
Example code
This code snippet shows how a local file can be loaded in TWebMemo
after having been picked by the TWebFilePicker
. From the TWebFilePicker.OnChange
event, the first picked file is accessed as text with GetFileAsText
and from the event TWebFilePicker.OnGetFileAsText
this text is added to a TWebMemo
.