Is it possible to upload all files in a folder at once without having to individually select each file? I know multiple files can be uploaded at once but I am trying to find a way to click on the folder and instead of each file because I am trying to upload several and it is quite tedius to click on each one.
Steps to reproduce
Code snippet:
if upload_images_button:
s.pressed_first_button = False
uploaded_file_raw = st.file_uploader("Choose a file", accept_multiple_files=True, type=["png","jpg","jpeg", "tif"])
If applicable, please provide the steps we should take to reproduce the error or specified behavior.
Desired behavior:
Upload multiple files by clicking on a folder.
Actual behavior:
Have to click on each image to upload.
Debug info
Streamlit version: (get it with $ streamlit version)
Python version: (get it with $ python --version)
Using Conda? PipEnv? PyEnv? Pex?
OS version:
Browser version:
Requirements file
Using Conda? PipEnv? PyEnv? Pex? Share the contents of your requirements file here.
Not sure what a requirements file is? Check out this doc and add a requirements file to your app.
Links
Link to your GitHub repo:
Link to your deployed app:
Additional information
If needed, add any other context about the problem here.
I don’t think we have a straightforward solution for this. However, we can use a workaround to enable bulk upload by incorporating predefined functions from Tkinter within the Streamlit web app.
The example below illustrates how to upload multiple PDF files by clicking on a folder. Similarly, we can change the source data format to .xlsx, .txt, etc
Code snippet:
import streamlit as st
import tkinter as tk
from tkinter import filedialog
import os
import pandas as pd
with st.sidebar:
root = tk.Tk()
root.withdraw()
root.wm_attributes('-topmost', 1)
st.write('Please select a folder:')
clicked = st.button('Browse Folder')
if clicked:
dirname = str(filedialog.askdirectory(master=root))
pdf_reports = [file for file in os.listdir(dirname) if file.endswith('.pdf')]
output = pd.DataFrame({"File Name": pdf_reports})
st.table(output)
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.