Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
89
rated 0 times [  93] [ 4]  / answers: 1 / hits: 20530  / 9 Years ago, tue, october 20, 2015, 12:00:00

Code that has been developed for a company that I am coaching uses Krajee's Bootstrap File Input. Where this function is called, allowedFileExtensions is set to allow only jpg, gif, and png. However, when the browse button is clicked, the list if allowed image file types shows about one dozen images types. If one that is not of the three types is selected, e.g., svg, the system shows an error message indicating that the file type is not allowed.



While this certainly works, the browse should only allow the chosen types to be selected. What additional parameter(s) and/or other changes are needed so that the browse window limits the selection to the chosen types?



If it matters: I have seen this behavior on a PC with both Firefox and IE.


More From » jquery

 Answers
14

While this certainly works, the browse should only allow the chosen
types to be selected. What additional parameter(s) and/or other
changes are needed so that the browse window limits the selection to
the chosen types?




Try setting accepted types of file extension for input type=file element using accept attribute , with value being file extensions separated by comma . Only file extnsion types defined as value of accept attribute should be displayed at Open File dialog





<input type=file accept=.jpg,.gif,.png />




[#64668] Sunday, October 18, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
randall

Total Points: 492
Total Questions: 99
Total Answers: 103

Location: Solomon Islands
Member since Fri, Oct 8, 2021
3 Years ago
randall questions
Wed, Mar 16, 22, 00:00, 2 Years ago
Tue, Nov 10, 20, 00:00, 4 Years ago
Sat, Oct 31, 20, 00:00, 4 Years ago
;