Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

3 lat temu
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # attr-accept
  2. JavaScript implementation of the "accept" attribute for HTML5 `<input type="file">`
  3. ![](https://github.com/react-dropzone/attr-accept/workflows/Test/badge.svg)
  4. [![npm version](https://badge.fury.io/js/attr-accept.svg)](https://badge.fury.io/js/attr-accept)
  5. [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
  6. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept for more information.
  7. Installation
  8. =====
  9. ```sh
  10. npm install --save attr-accept
  11. ```
  12. Usage
  13. =====
  14. ```javascript
  15. var accept = require('attr-accept');
  16. accept({
  17. name: 'my file.png',
  18. type: 'image/png'
  19. }, 'image/*') // => true
  20. accept({
  21. name: 'my file.json',
  22. type: 'application/json'
  23. }, 'image/*') // => false
  24. accept({
  25. name: 'my file.srt',
  26. type: ''
  27. }, '.srt') // => true
  28. ```
  29. You can also pass multiple mime types as a comma delimited string or array.
  30. ```javascript
  31. accept({
  32. name: 'my file.json',
  33. type: 'application/json'
  34. }, 'application/json,video/*') // => true
  35. accept({
  36. name: 'my file.json',
  37. type: 'application/json'
  38. }, ['application/json', 'video/*']) // => true
  39. ```