Skip to content
Related Articles

Related Articles

How to Select Multiple Files using HTML Input Tag ?
  • Last Updated : 27 Feb, 2020

Using the input tag to upload multiple files has become possible after the release of HTML 5. Since many of us, work on HTML and still use tags such as <input> tag for taking input from the user and <form> tag for using forms on our website, it is necessary to know how to implement multiple files feature using HTML. We can assign ‘multiple’ attribute with the value of multiple like below:
Syntax:

<input type="file" id="files" name="files" multiple="multiple">

OR

<input type="file" id="files" name="files" multiple>

Note: We can use just multiple as a property. Well, it is very simple. HTML 5 has a property for input tag which is ‘multiple’.

Below example illustrates the above approach:

Example: Using this property, you can input multiple files. For selecting files, you must use either CTRL or SHIFT and select the number of files to be uploaded.






<!DOCTYPE html>
<html>
  
<head>
    <title>
        Select multiple files using HTML Input tag
    </title>
    <style>
        h1 {
            color: green;
        }
          
        .container {
            text-align: center;
            width: 850px;
            margin: 35px;
        }
          
        .property {
            width: 400px ;
            float: left;
            border: 2px solid black;
            padding: 10px;
        }
        .attribute {
            width: 400px ;
            float: right;
            border: 2px solid black;
            padding: 10px;
        }
    </style>
</head>
  
<body>
    <div class="container">
        <h1>GeeksforGeeks</h1>
        <b>A Computer Science Portal for Geeks</b>
        <br><br>
        <div class="property">
            <p>
                Input Multiple Files using Input Tag, 
                <b>'multiple property'</b>
            </p>
            <form action="/action_page_inputtags_multiplefiles.php">
                <label for="files">Select Multiple files:</label>
                <input type="file" id="files" name="files" multiple>
            </form>
        </div>
        <div class="attribute">
            <p>
                Input Multiple Files using Input Tag, 
                <b>'multiple attribute'</b>
            </p>
            <form action="/action_page_inputtags_multiplefiles.php">
                <label for="files">Select Multiple files:</label>
                <input type="file" id="files" name="files" 
                                              multiple="mutliple">
            </form>
        </div>
</body>
  
</html>

Output:

But if you are using HTML 4 or lower versions of HTML than, either you need to use multiple input tags or you may use plugins such as Flash or Silverlight to insert multiple input files. You may also use JavaScript to upload multiple files. However, the use of HTML 4 and lower versions are not encouraged as with HTML 5, many new features have been introduced, as well as the dependency of using third-party plugins for various operations is reduced significantly. By the use of multiple properties of the input tag, you can upload multiple files.

full-stack-img

My Personal Notes arrow_drop_up
Recommended Articles
Page :