You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Upload component can be used to upload filesto the server.
17
+
Reflex makes it simple to add file upload functionality to your app. You can let users select files, store them on your server, and display or process them as needed. Below is a minimal example that demonstrates how to upload files, save them to disk, and display uploaded images using application state.
16
18
17
-
You can pass components as children to customize its appearance.
18
-
You can upload files by clicking on the component or by dragging and dropping files onto it.
19
19
20
-
```python demo
21
-
rx.upload(
22
-
id="my_upload",
23
-
)
20
+
## Basic File Upload Example
21
+
22
+
You can let users upload files and keep track of them in your app’s state. The example below allows users to upload files, saves them using the backend, and then displays the uploaded files as images.
@@ -271,6 +427,24 @@ The backend of your app will mount this uploaded files directory on `/_upload` w
271
427
# When using the Reflex hosting service, the uploaded files directory is not persistent and will be cleared on every deployment. For persistent storage of uploaded files, it is recommended to use an external service, such as S3.
272
428
```
273
429
430
+
### Directory Structure and URLs
431
+
432
+
By default, Reflex creates the following structure:
433
+
434
+
```text
435
+
your_project/
436
+
├── uploaded_files/ # rx.get_upload_dir() points here
The `id` provided to the `rx.upload` component can be passed to the special event handler `rx.cancel_upload(id)` to stop uploading on demand. Cancellation can be triggered directly by a frontend event trigger, or it can be returned from a backend event handler.
0 commit comments