question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Are file extensions supported in accept attribute?

See original GitHub issue

I need to accept files by extension instead of MIME type. It is supported by browsers, but react-dropzone rejects all files when i specify an extension.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9

github_iconTop GitHub Comments

3reactions
rolandjitsucommented, Nov 19, 2018

@nofearOnline should be as easy as <Dropzone accept=".stl" />.

2reactions
rolandjitsucommented, Nov 19, 2018

onDrop emits a js array, so use .slice(0, maxItems):

class Basic extends React.Component {
  onDrop = acceptedFiles => {
    const files = acceptedFiles.slice(0, 10) // 10 max files
  }

  render() {
    return (
      <Dropzone
        onDrop={this.onDrop}
      >
        <p>Try dropping some files here, or click to select files to upload.</p>
      </Dropzone>
    );
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

<input type="file"> - HTML: HyperText Markup Language | MDN
Acceptable file types can be specified with the accept attribute, which takes a comma-separated list of allowed file extensions or MIME types. ...
Read more >
Accept Attribute with File extensions - W3C Wiki
The accept attribute is intended to help authors scope the list of files for a user to choose from. The current options available...
Read more >
html - File input 'accept' attribute - is it useful? - Stack Overflow
Indicates that files with the specified file extension are accepted. ... Yes, it is extremely useful in browsers that support it, but the...
Read more >
accept attribute for file input | Can I use... Support ... - CanIUse
1 Supports the type format (e.g. image/* ) but not the extension format (e.g. .png ) · 2 Offers appropriate file locations/input based...
Read more >
HTML5 Forms: Accept Attribute - Wufoo
The accept attribute takes a comma-separated list of unique content types of files that are acceptable values for the file input type only....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found