Debian Codegraph @

node/attr-accept/README.md

raw
1 # attr-accept
2 > JavaScript implementation of the "accept" attribute for HTML5 `<input type="file">`
3
4 [![npm](https://img.shields.io/npm/v/attr-accept.svg?style=flat-square)](https://www.npmjs.com/package/attr-accept)
5 ![Tests](https://img.shields.io/github/actions/workflow/status/react-dropzone/attr-accept/test.yml?branch=master&style=flat-square&label=tests)
6
7 See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#attr-accept for more information.
8
9 ## Installation
10 ```sh
11 npm install --save attr-accept
12 ```
13
14 ## Usage
15 ```javascript
16 var accept = require('attr-accept');
17 accept({
18 name: 'my file.png',
19 type: 'image/png'
20 }, 'image/*') // => true
21
22 accept({
23 name: 'my file.json',
24 type: 'application/json'
25 }, 'image/*') // => false
26
27 accept({
28 name: 'my file.srt',
29 type: ''
30 }, '.srt') // => true
31 ```
32
33 You can also pass multiple mime types as a comma delimited string or array.
34 ```javascript
35 accept({
36 name: 'my file.json',
37 type: 'application/json'
38 }, 'application/json,video/*') // => true
39
40 accept({
41 name: 'my file.json',
42 type: 'application/json'
43 }, ['application/json', 'video/*']) // => true
44 ```
45
46 ## Contributing
47
48 Checkout the organization [CONTRIBUTING.md](https://github.com/react-dropzone/.github/blob/main/CONTRIBUTING.md).