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

FileUpload: Validate files before adding on drop #2690

Closed
wolnynick opened this issue Mar 21, 2022 · 4 comments · Fixed by #2789
Closed

FileUpload: Validate files before adding on drop #2690

wolnynick opened this issue Mar 21, 2022 · 4 comments · Fixed by #2789
Assignees
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@wolnynick
Copy link

[ ] bug report
[X] feature request
[ ] support request => Please do not submit support request here, instead see https://forum.primefaces.org/viewforum.php?f=57

Current behavior
There is no validation which types goes into file uploader

Expected behavior
Please add validation to FileUploader based on accept property. Or tell me how can I validate by myself and then remove items. I tried to remove wrong files on 'onSelect' event, but it's not working with

fileUploadRef.current.state.files = []
fileUploadRef.current.files = []
e.files = {}
e.originalEvent.dataTransfer.files[0] = {}

Minimal reproduction of the problem with instructions
FileUpload -> multiple: true -> mode: advanced

  • PrimeReact version:
    7.2.1
@melloware
Copy link
Member

Can you give me the example accept value you are using?

@wolnynick
Copy link
Author

wolnynick commented Mar 21, 2022

accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"

And I should mention it earlier, that I'm talking about drag and drop

@yigitfindikli yigitfindikli added the Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add label Mar 31, 2022
@yigitfindikli yigitfindikli added this to the Future milestone Mar 31, 2022
@melloware melloware changed the title Validate files in FileUpload before adding FileUpload: Validate files before adding on drop Apr 21, 2022
@melloware
Copy link
Member

melloware commented Apr 22, 2022

I think we need to add an onBeforeDrop method so you can hook in and return false; if you don't want the drop to proceed.

@melloware
Copy link
Member

Especially from the HTML5 docs for accept:

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept

For instance, there are a number of ways Microsoft Word files can be identified, so a site that accepts Word files might use an like this:

<input type="file" id="docpicker"
  accept=".doc,.docx,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document">

melloware added a commit to melloware/primereact that referenced this issue Apr 29, 2022
@mertsincan mertsincan modified the milestones: 8.1.0, 8.1 May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants