Published on

How to Enable Multiple File Selection for HTML Input Element

Authors
  • avatar
    Name
    TekLoon
    Twitter

Problem

We could only select/upload one image file at a time with below code.

<input
    className="hidden"
    type="file"
    accept="image/*"
    onChange={handleImageUpload}
    ref={imagesInputRef}
/>

Solution

We could enable multiple file selection by adding multiple attribute to the input element.

<input
    +multiple
    className="hidden"
    type="file"
    accept="image/*"
    onChange={handleImageUpload}
    ref={imagesInputRef}
/>