Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task done
Jocelyne-Smith opened this issue Aug 13, 2024 · 6 comments · Fixed by #9431
Closed
1 task done
Assignees
Labels
bug Something isn't working
Milestone

Comments

@Jocelyne-Smith
Copy link

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? 🔎

  • I have searched and found no 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

@Jocelyne-Smith Jocelyne-Smith added the bug Something isn't working label Aug 13, 2024
@freddyaboulton
Copy link
Collaborator

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
Copy link
Collaborator

Can't reproduce on the PDF component either!

@Jocelyne-Smith
Copy link
Author

Jocelyne-Smith commented Aug 13, 2024

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
Copy link
Member

Duplicate of: #8662, I'll actually close #8662 since this has more useful context

@freddyaboulton
Copy link
Collaborator

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

@abidlabs
Copy link
Member

abidlabs commented Oct 1, 2024

Closed via #9431 in 5.0-dev branch

@abidlabs abidlabs closed this as completed Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants