Checking file input type in React.js

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Checking file input type in React.js



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?




1 Answer
1



You can add the accept="" attribute to your <input type="file"> to allow the user to only select files of a certain type.


accept=""


<input type="file">



For instance,


<input type="file" accept="video/*">



will accept all video, and


<input type="file" accept=".mp4,.flv">



will accept files with those extensions.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard