How to add an HTML file input that only allows a user to select only one file?

Sometimes, we want to add an HTML file input that only allows a user to select only one file.

In this article, we’ll look at how to add an HTML file input that only allows a user to select only one file.

How to add an HTML file input that only allows a user to select only one file?

To add an HTML file input that only allows a user to select only one file, we can add a file input without the multiple attribute.

For instance, we write:

<input type="file" id="file" name="file" />

to add a file input that only allows us to select a single file.

Conclusion

To add an HTML file input that only allows a user to select only one file, we can add a file input without the multiple attribute.