How to limit file format when using an HTML file input?

Spread the love

Sometimes, we want to limit file format when using an HTML file input.

In this article, we’ll look at how to limit file format when using an HTML file input.

How to limit file format when using an HTML file input?

To limit file format when using an HTML file input, we can set the accept attribute.

For instance, we write

<input type="file" accept=".xls,.xlsx" />

to add the input element with the accept attribute set to a list of file extensions that are accepted by the file input separated by commas.

Conclusion

To limit file format when using an HTML file input, we can set the accept attribute.

Leave a Reply

Your email address will not be published.