gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
32.11k stars 2.4k forks source link

File and PDF Components Allowing Unsupported Files to be Uploaded via 'Click to Upload' #9098

Open Jocelyne-Smith opened 1 month ago

Jocelyne-Smith commented 1 month ago

Describe the bug

When using 'click to upload' on a gradio File component, a user is able to select files that are not specified in the file_types=[]. Similarly a user can upload a non-PDF file when using the 'click to upload' for the gradio PDF component. The same 'Invalid file type only x allowed' error should probably be displayed when a user tries to upload an invalid file type.

Have you searched existing issues? 🔎

Reproduction

import gradio as gr

submissions_zip_filepath = gr.File(label="Student Solutions (.zip)",
                                               type="filepath", 
                                               file_types=['.zip'], 
                                               interactive=True)

Screenshot

image

Logs

No response

System Info

gradio                    4.41.0
gradio_client             1.3.0
gradio_pdf                0.0.13

Severity

I can work around it

freddyaboulton commented 1 month ago

I can't repro the issue with the gr.File component @Jocelyne-Smith . Anything that's not a .zip is not allowed by my file picker.

image

I will take a look separately at the PDF component.

freddyaboulton commented 1 month ago

Can't reproduce on the PDF component either!

Jocelyne-Smith commented 4 weeks ago

Hi @freddyaboulton.

Thank you for taking a look so quickly!

My apologies, I should have included more information.

I am running on windows.

First open the file explorer by clicking on 'Click to upload'.

image

Then click on the dropdown as shown in red. Select 'All Files'.

image

Select any invalid file type. In my example I uploaded a .jpg in the .zip component.

Heres the code of the component:

submissions_zip_filepath = gr.File(label="Student Solutions (.zip)", type="filepath", file_types=['.zip'], interactive=True)

I was able to upload a .jpg to the component that only accepts .zip file_types. I did not receive any error or warning.

image

The same issue can be found on the gradio PDF component with the steps as described above.

I uploaded a .jpg in the PDF component.

image

I did try it on a different PC with the newest gradio and its dependencies.

My apologies I am not sure what the same steps would be on MacOS.

Your help would be really appreciated!

Thank you.

abidlabs commented 4 weeks ago

Duplicate of: https://github.com/gradio-app/gradio/issues/8662, I'll actually close https://github.com/gradio-app/gradio/issues/8662 since this has more useful context

freddyaboulton commented 4 weeks ago

Gotcha @Jocelyne-Smith - looks like its a windows issue then!