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

ngf-accept file filtering doesn't seem to work #755

Closed
kruegeGH opened this issue May 22, 2015 · 12 comments
Closed

ngf-accept file filtering doesn't seem to work #755

kruegeGH opened this issue May 22, 2015 · 12 comments

Comments

@kruegeGH
Copy link

I've noticed that ngf-accept doesn't seem to work when you try to use it to filter for specific files. Even on the jsfiddle demo if you change the accept attributes over to ngf-accept the filtering no longer works. You can see this in jsfiddle http://jsfiddle.net/3t50b3fw/401/ for example.

This issue happens to me in Chrome, Firefox, and Internet Explorer.

@danialfarid
Copy link
Owner

What is not working? Steps to reproduce

@kruegeGH
Copy link
Author

Well I'm not quite sure how to be more clear than I was since my original post mentioned what isn't working and also mentioned how to reproduce it as well as included a jsfiddle recreating the issue but I'll try explaining it again.

In the reference section on the github it mentions the following for ngf-accept:
ngf-accept="'.pdf,.jpg'|validate($file)" // function or comma separated wildcard to filter files allowed

I've tried the following combinations (with and without single quotes just to see if it would make a difference) and none of them filter for the specific file types I listed.
ngf-accept=".pdf,.jpg"
ngf-accept="'.pdf,.jpg'"
(I have also tried image/* and that also doesn't work.)

When the browser's file select dialog box pops up it still shows all file types instead of just the ones I listed as filters.

I created another fiddle for you which is also based off the sample demo fiddle. Hopefully this one makes it more clear what isn't working:
http://jsfiddle.net/3t50b3fw/417/

@danialfarid
Copy link
Owner

the browser file popup filter is browser specific and is controlled by accept attribute, ngf-accept is just filtering after the files are selected and set the files into ng-model or ng-model-rejected based on wether they are accepted or not

@kruegeGH
Copy link
Author

Ah, ok. I did do some more tinkering around with it after your explanation and I see how it's supposed to work now. The descriptions on the main github page for how to use some of the options in conjunction with the other options are a bit vague. Also it might be helpful to note which ones are required options and which ones are strictly optional.

Thanks for the assistance though. I'll go ahead and close out this issue.

@danialfarid
Copy link
Owner

If you have suggestion to make it more clear let me know.
I added a note for ngf-drop optional attributes.

@kruegeGH
Copy link
Author

I do have a few suggestions listed below if you would like to implement them.

I would suggest adding a similar note to ngf-select as you did for ngf-drop since not all attributes are required for ngf-select either.

For the ngf-accept attribute maybe you could add a comment that says it is used to filter out the files after they have been selected and discards or accepts them based on whether or not they meet the filter criteria. Then on the accept attribute comment you could a small statement that says it is used to filter the files before selection. Doing that would make it really clear that the accept attribute is used to filter files before they are selected and ngf-accept is used to filter files after they are selected.

The only other thing I can think of is that it might be a good idea to mention somewhere that by default ng-file-upload won't inform you in any way if a file fails to meet the pattern in ngf-accept. You have to either use ng-model-rejected to see that a file failed or you would need to write your own function that you would pass into ngf-accept to inform you that a file failed. I only mention this because when I was first trying to implement ng-file-upload I kept looking for some kind of informational message in both the browser's debug console and on the page itself to see why my file wasn't getting set in ng-model.

@cipianpascu
Copy link

cipianpascu commented May 22, 2016

ngf-accept is case sensitive. it shouldn't. this happened to me on ubuntu.

@danialfarid
Copy link
Owner

@cipianpascu create a separate issue for that.

@cipianpascu
Copy link

Hi Danial,
Thought it was related with this one. :)
New incident created at 1546
Regards,
Ciprian

@default0
Copy link

From the Readme:

*ngf-accept="'image/*'" // standard HTML accept attr, browser specific select popup window

This is very confusing. After reading that I assumed that ngf-accept was a ngf-specific way to get the functionality of the normal "accept" attribute. Only after a bunch of googling did I stumble on this issue and found your explanation of what it actually is.
It would be much appreciated if the documentation in the readme could be clearer about that.

@priiduneemre
Copy link

priiduneemre commented Dec 1, 2016

@default0 Same here, +1.

@alvint
Copy link

alvint commented Sep 25, 2017

Yes, VERY confusing. Wasted an hour on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants