https://github.com/react-dropzone/attr-accept
JavaScript implementation of the "accept" attribute for HTML5 input element
https://github.com/react-dropzone/attr-accept
file file-validation
Last synced: 5 months ago
JSON representation
JavaScript implementation of the "accept" attribute for HTML5 input element
- Host: GitHub
- URL: https://github.com/react-dropzone/attr-accept
- Owner: react-dropzone
- License: mit
- Created: 2015-09-08T17:20:13.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2024-11-25T12:23:13.000Z (over 1 year ago)
- Last Synced: 2025-06-09T23:03:15.851Z (11 months ago)
- Topics: file, file-validation
- Language: JavaScript
- Homepage:
- Size: 1.41 MB
- Stars: 114
- Watchers: 7
- Forks: 24
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# attr-accept
> JavaScript implementation of the "accept" attribute for HTML5 ``
[](https://www.npmjs.com/package/attr-accept)

See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#attr-accept for more information.
## Installation
```sh
npm install --save attr-accept
```
## Usage
```javascript
var accept = require('attr-accept');
accept({
name: 'my file.png',
type: 'image/png'
}, 'image/*') // => true
accept({
name: 'my file.json',
type: 'application/json'
}, 'image/*') // => false
accept({
name: 'my file.srt',
type: ''
}, '.srt') // => true
```
You can also pass multiple mime types as a comma delimited string or array.
```javascript
accept({
name: 'my file.json',
type: 'application/json'
}, 'application/json,video/*') // => true
accept({
name: 'my file.json',
type: 'application/json'
}, ['application/json', 'video/*']) // => true
```
## Contributing
Checkout the organization [CONTRIBUTING.md](https://github.com/react-dropzone/.github/blob/main/CONTRIBUTING.md).