attr-accept
JavaScript implementation of the "accept" attribute for HTML5 <input type="file">
Last updated 6 years ago by rolandjitsu .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install attr-accept 
SYNC missed versions from official npm registry.

attr-accept

JavaScript implementation of the "accept" attribute for HTML5 <input type="file">

npm version semantic-release

See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept for more information.

Installation

npm install --save attr-accept

Usage

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.

accept({
    name: 'my file.json',
    type: 'application/json'
}, 'application/json,video/*') // => true

accept({
    name: 'my file.json',
    type: 'application/json'
}, ['application/json', 'video/*']) // => true

Current Tags

  • 3.0.0-beta.1                                ...           beta (2 years ago)
  • 4.0.1                                ...           latest (2 months ago)

20 Versions

  • 4.0.1                                ...           2 months ago
  • 4.0.0                                ...           4 months ago
  • 3.0.0-beta.1                                ...           2 years ago
  • 3.0.0 [deprecated]           ...           2 years ago
  • 2.2.5                                ...           2 years ago
  • 2.2.4                                ...           2 years ago
  • 2.2.3                                ...           2 years ago
  • 2.2.2                                ...           6 years ago
  • 2.2.1                                ...           6 years ago
  • 2.2.0                                ...           6 years ago
  • 2.1.0                                ...           7 years ago
  • 2.0.0                                ...           7 years ago
  • 1.1.3                                ...           8 years ago
  • 1.1.2                                ...           9 years ago
  • 1.1.1                                ...           9 years ago
  • 1.1.0                                ...           10 years ago
  • 1.0.3                                ...           11 years ago
  • 1.0.2                                ...           11 years ago
  • 1.0.1                                ...           11 years ago
  • 1.0.0                                ...           11 years ago
Downloads
Total 39
Today 0
This Week 1
This Month 7
Last Day 0
Last Week 2
Last Month 31
Dependencies (0)
None
Dependents (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE