Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

docs: fix file upload docs (#5788)

Srihari Thyagarajan67b02cb315c2
diff --git a/docs/api/inputs/file.md b/docs/api/inputs/file.md
index d2e568c258..59ee3d317c 100644
--- a/docs/api/inputs/file.md
+++ b/docs/api/inputs/file.md
@@ -5,7 +5,26 @@
```python
@app.cell
def __():
- mo.vstack([mo.ui.file(kind="button"), mo.ui.file(kind="area")])
+ file_button = mo.ui.file(kind="button")
+ file_area = mo.ui.file(kind="area")
+ return file_area, file_button
+```
+
+```python
+def _(file_area, file_button, mo):
+ mo.vstack([file_button, file_area])
+ return
+```
+
+```python
+def _(file_area, file_button, mo):
+ # Access uploaded files
+ mo.vstack([
+ mo.md(f"Button upload: {file_button.name() if file_button.value else 'No file'}"),
+ mo.md(f"Area upload: {file_area.name() if file_area.value else 'No file'}")
+ ])
return
```
diff --git a/marimo/_plugins/ui/_impl/input.py b/marimo/_plugins/ui/_impl/input.py
index ceb5cb928c..a05271c33d 100644
--- a/marimo/_plugins/ui/_impl/input.py
+++ b/marimo/_plugins/ui/_impl/input.py
@@ -1292,8 +1292,11 @@ class file(UIElement[list[tuple[str, str]], Sequence[FileUploadResults]]):
Uploading a single file:
```python
f = mo.ui.file()
+ f
+ ```
- # access the uploaded file's name
+ ```python
+ # In another cell, access the uploaded file's name
f.value[0].name
# or
f.name()
@@ -1307,8 +1310,11 @@ class file(UIElement[list[tuple[str, str]], Sequence[FileUploadResults]]):
Uploading multiple files, accepting only .png and .jpg extensions:
```python
f = mo.ui.file(filetypes=[".png", ".jpg"], multiple=True)
+ f
+ ```
- # access an uploaded file's name
+ ```python
+ # In another cell, access an uploaded file's name
f.value[index].name
# or
f.name(index)