file_selector¶
Allows uploading a file content.
The upload can be triggered by pressing a button, or drag-and-dropping a file on top of the control.
Properties¶
Name | Type | Default | Description |
---|---|---|---|
(★) |
dynamic(str) | The path or the list of paths of the uploaded files. |
|
label |
str | The label of the button. |
|
on_action |
Callback | The name of the function that will be triggered.
|
|
multiple |
bool | False | If set to True, multiple files can be uploaded. |
extensions |
str | ".csv,.xlsx" | The list of file extensions that can be uploaded. |
drop_message |
str | "Drop here to Upload" | The message that is displayed when the user drags a file above the button. |
active |
dynamic(bool) | True | Indicates if this component is active. |
id |
str | The identifier that will be assigned to the rendered HTML component. |
|
properties |
dict[str, Any] | Bound to a dictionary that contains additional properties for this element. |
|
class_name |
dynamic(str) | List of CSS class names that will be associated with the generated HTML Element. |
|
hover_text |
dynamic(str) | Information that is displayed when the user hovers over this element. |
(★)content
is the default property for this visual element.
Styling¶
All the file selector controls are generated with the "taipy-file_selector" CSS class. You can use this class name to select the file selector controls on your page and apply style.
Usage¶
Default behavior¶
The variable specified in content is populated by a local filename when the transfer is completed.
Page content
<|{content}|file_selector|>
<taipy:file_selector>{content}</taipy:file_selector>
Standard configuration¶
A specific label can be shown besides the standard icon. The function name provided as on_action is called when the transfer is completed. The extensions property can be used as a list of file name extensions that is used to filter the file selection box. This filter is not enforced: the user can select and upload any file. Upon dragging a file over the button, the drop_message content is displayed as a temporary label for the button.
Page content
<|{content}|file_selector|label=Download File|on_action=function_name|extensions=.csv,.xlsx|drop_message=Drop Message|>
<taipy:file_selector on_action="function_name" extensions=".csv,.xlsx" drop_message="Drop Message">{content}</taipy:file_selector>
Multiple files upload¶
The user can transfer multiple files at once by setting the multiple property to True.
Page content
<|{content}|file_selector|multiple|>
<taipy:file_selector multiple="True">{content}</taipy:file_selector>