Reputation: 57
I am a newb to react and was trying to find a function to check for specific file format type(mp4,flv,,ect) when ever i upload something using react besides using dropzone?
Upvotes: 3
Views: 12408
Reputation: 61
Note that the accept
attribute doesn't work as a validation tool, as files should be validated on the server.
The accept
attribute used for hinting the browser to show files that match the value of accept
.
Therefore the user will be able to choose any file type he wants.
Upvotes: 6
Reputation: 169416
You can add the accept=""
attribute to your <input type="file">
to allow the user to only select files of a certain type.
For instance,
<input type="file" accept="video/*">
will accept all video, and
<input type="file" accept=".mp4,.flv">
will accept files with those extensions.
Upvotes: 9