Hi, the following example might help for your use case. It’s a modification from: Upload Files to Streamlit App
import os
import streamlit as st
def file_selector(folder_path='.'):
filenames = os.listdir(folder_path)
selected_filename = st.selectbox('Select a file', filenames)
return os.path.join(folder_path, selected_filename)
if __name__ == '__main__':
# Select a file
if st.checkbox('Select a file in current directory'):
folder_path = '.'
if st.checkbox('Change directory'):
folder_path = st.text_input('Enter folder path', '.')
filename = file_selector(folder_path=folder_path)
st.write('You selected `%s`' % filename)
# TODO: Add code to open and process your image file