The page must start with a single button:
And when I click "Upload File", a file_uploader must appear.
It works until here. However, If I click "Browse files" and upload a 2kb CSV file, file_uplader disappears from the page, and "You selected the file:" is not printed.
Here is my code:
import streamlit as st
if st.button('Upload File'):
uploaded_file = st.file_uploader("Choose a file")
print(uploaded_file)
if uploaded_file is not None:
# print(uploaded_file)
st.write("You selected the file:", uploaded_file.name)
First print returns "None" in the terminal.
If I try the same code for a selectbox
, the same thing is happening. It shows options in the menu, but if I select one, the dropdown menu disappears.
How can I create a file_uploader with a button, and use the file_uploader without any problem in the streamlit app?