0

I want to restrict users to only upload images of certain formats. For this, I want to pass multiple file types in the accept prop of Form.File. I can only find examples with one file type only. Below is my code so far:

<InputGroup >
    <Form.Group>
        <Form.File 
         onChange={(e) => setGamePhoto(e.target.files[0])}
         label="Upload The End-Game Photo"
         accept=".png"
        />
   </Form.Group>
</InputGroup>

I want to pass multiple file types like png, jpg, jpeg, web etc

1 Answer 1

2

You can insert it in the form of a comma , separated list. Try this:

<InputGroup >
    <Form.Group>
        <Form.File 
         onChange={(e) => setGamePhoto(e.target.files[0])}
         label="Upload The End-Game Photo"
         accept=".png,.jpg,.jpeg,.webp"
        />
   </Form.Group>
</InputGroup>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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