viclafouch / mui-file-input

A file input designed for the React library MUI
https://viclafouch.github.io/mui-file-input/
MIT License
77 stars 17 forks source link

Implement `accept` #8

Closed kevinhikaruevans closed 1 year ago

kevinhikaruevans commented 1 year ago

Is your feature request related to a problem? Please describe. I would like to filter the types of files the user can upload, e.g. accept=".txt,text/plain"

Describe the solution you'd like Pass the accept prop to the file input

https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept

Describe alternatives you've considered N/A

Additional context N/A

viclafouch commented 1 year ago

Hey !

You can achieve that by using the inputProps property :

<MuiFileInput
  placeholder="Choisir un fichier"
  inputProps={{
    accept: 'video/*'
  }}
/>

See here : https://viclafouch.github.io/mui-file-input/docs/api-reference/#inputprops--accept

iliazeus commented 1 year ago

@viclafouch can you please document it in the API reference? Multiple people (including me) thought it wasn't possible before stumbling onto this issue.

viclafouch commented 1 year ago

Got it !

viclafouch commented 1 year ago

Here the documentation : https://viclafouch.github.io/mui-file-input/docs/api-reference/#inputprops--accept