how to copy the uploaded file to the upload folder #496
-
I want to ask . how to copy the resulting file that I uploaded to the uploads folder import shutil
from nicegui import ui
def on_upload(event):
# Mendapatkan nama file yang diunggah
print(x)
file_name = event.name
print(e)
# Menyalin file ke direktori uploads
src_path = event.path
dst_path = './uploads/' + file_name
shutil.copy(src_path, dst_path)
ui.notify(f'{file_name} uploaded and saved to uploads folder')
ui.upload(on_upload=on_upload).classes('max-w-full')
ui.run() thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Please see #283 for a related discussion. |
Beta Was this translation helpful? Give feedback.
-
I'm still confused why the upload file is useless for uploading. instead use something else namely local file picker . Then what is the function of the upload file if u can't do it Upload files |
Beta Was this translation helpful? Give feedback.
Please see #283 for a related discussion.
There is no
path
in the upload event. So you can't copy the file but need to write a new one with the data fromevent.content
.Or you use something like the local file picker.