File_uploader - How to clear the list of uploaded files?

With the option accept_multiple_files=True , the list of files grows with each upload activity. How do I clear this list? Deleting the corresponding key or assigning an empty list does not help. Only thing that helps is the reload button of the browser… If I didnt overlook something I suggest to add an option to control this (upload_method = ‘replace’ | ‘append’)

1 Like

Hi @ksxx,

You should be able to do the following:

with st.form("my-form", clear_on_submit=True):
        file = st.file_uploader("upload file")
        submitted = st.form_submit_button("submit")

Thank you - this works indeed!