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. There is no validation for accept types #1694

Closed
Invizible opened this issue Dec 27, 2016 · 6 comments
Closed

FileUpload. There is no validation for accept types #1694

Invizible opened this issue Dec 27, 2016 · 6 comments
Assignees
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@Invizible
Copy link
Contributor

Currently we can set allowed types using 'accept' attribute, but component actually does not perform any validation and we can upload any file.

@kt215
Copy link
Contributor

kt215 commented Dec 28, 2016

Do you mean when you select "All Files" in the file dialog?

I encountered this issue too, and I validate the uploaded file contents of the server side using binary validation.

What exactly do you want primeng to do on the client side?

@Invizible
Copy link
Contributor Author

@kt215 , Yes you are right, if we select "All Files" we can upload everything.
You can take a look at my pull request. We can do file type check the same way we have validation for file size.

@bhamde
Copy link

bhamde commented Jan 23, 2017

any updates on when that change is going in? quite an important bug fix

@cagataycivici cagataycivici self-assigned this Mar 27, 2017
@cagataycivici cagataycivici added the Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add label Mar 27, 2017
@cagataycivici cagataycivici added this to the 4.0.RC2 milestone Mar 27, 2017
@cagataycivici
Copy link
Member

Merged

cagataycivici pushed a commit that referenced this issue Mar 27, 2017
@EddyP23
Copy link

EddyP23 commented Apr 18, 2017

@cagataycivici

Current implementation is very confusing and actually wrong.

Say, I pass accept='image/jpeg,image/bmp'. Then method isFileTypeValid (here)
does very strange things.

If it finds a * in accepted type (say image/jpeg or image/*), it checks whether first part of the mime-type image matches the mime type of the file.
If it doesn't find a star, then it compares file extension (e.g. .jpg) to mime type (e.g. image/jpeg) which is completely wrong.

Could you please reopen and fix it?

@AlissonRS
Copy link

When I click the draggable area, the browser window to select files will be pre-loaded correctly based on the accept input, but if I just change to "All Files" or just drag a file, the component won't prevent those files.

Currently using: "primeng": "^7.1.3". As an example, I'm using it like this:

<p-fileUpload accept=".psd,.idml" (onUpload)="onUpload($event)">

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

No branches or pull requests

6 participants