import streamlit as st import os path = "/data" # Define the modal dialog function @st.dialog("Upload a File") def upload_file(): uploaded_file = st.file_uploader("Choose a file") if uploaded_file is not None: file_details = {"FileName":uploaded_file.name,"FileType":uploaded_file.type} st.write(file_details) with open(os.path.join(path,uploaded_file.name),"wb") as f: f.write(uploaded_file.getbuffer()) st.success("Saved File") # Main app st.write("Click the button to open the file upload dialog.") if st.button("Open File Dialog"): upload_file() # List all files in directory and subdirectories files = [] for root, dirs, file_names in os.walk(path): for file_name in file_names: files.append(os.path.join(root, file_name)) st.write(files)