Upload Files to Streamlit App

Here’s another, perhaps slightly less janky ad-hoc file selector on the server:

import streamlit as st
import os

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)

filename = file_selector()
st.write('You selected `%s`' % filename)

And here’s what it looks like:

Of course, these file selectors can be improved a lot, but these examples illustrate that fairly complex and useful UIs can be built using existing Streamlit primitives.

10 Likes