3

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?

2 Answers 2

9

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.

Sign up to request clarification or add additional context in comments.

Comments

6

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.