Keep the file uploaded

i uploaded a file in one tab and used the file in other tab. using the code below

if selected == “Upload”:
st.title(f"You have selected {selected}")
uploaded_file = st.file_uploader(“Upload your input file”, type=[‘csv’], key=“uploaded_file”)

after uploading the second tab displays the dataset. the second tab has a dropdown menu. when selecting the other functions. the uploaded file is not loaded. and it asks to upload the file again.

Even if the uploaded file doesn’t show up in the uploader anymore, it should be available in st.session_state["uploaded_file"], since you set key="uploaded_file" in the uploader. You should be able to use that entry in session_state to access the previously-uploaded file.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.