About download multiple images using single download button in streamlit

How can I add single download button which enables to download multiple images.

1 Like

You could make a .zip file beforehand with the python standard library zipfile and only download one zip file?

Hi !! thanks for the solution but I tried this, still multiple download buttons are created which means one download button for one image.
Here is my code
if hasFrames:

            name = 'image' + str(count) + '.jpg'


            cv2.imwrite(name, image)

            # create a ZipFile object

            zipObj = ZipFile("sample.zip", "w")

            # Add multiple files to the zip



            # close the Zip File


            ZipfileDotZip = "sample.zip"

            with open(ZipfileDotZip, "rb") as file:

                bytes = file.read()

                b64 = base64.b64encode(bytes).decode()

                href =  f"<a href=\"data:file/zip;base64,{b64}\" download='{ZipfileDotZip}.zip'>Download image</a>"        

            st.markdown(href, unsafe_allow_html=True)

            return hasFrames

would you please suggest how to fix this issue?

Have a look here:

Hi Franky
Thanks for the solution…
It works for me… :innocent: