This commit is contained in:
markrz12 2023-12-12 21:28:17 +01:00
parent ec7c3861dd
commit 02d712614f
1 changed files with 2 additions and 4 deletions

View File

@ -24,21 +24,19 @@ class State(rx.State):
# The images to show.
img: list[str] = []
async def handle_upload(self, files: list[rx.UploadFile]):
"""Handle the upload of file(s).
Args:
files: The uploaded files.
"""
for file in files:
upload_data = await file.read()
outfile = rx.get_asset_path(file.filename)
# Save the file.
with open(outfile, "wb") as file_object:
file_object.write(upload_data)
# Update the img var.
self.img.append(file.filename)
self.img = self.img