Javascript Reference - HTML DOM Input FileUpload multiple Property








The multiple property sets or gets whether more than one file can be selected.

Browser Support

multiple Yes 10.0 Yes Yes Yes

Syntax

Return the multiple property.

var v = fileuploadObject.multiple

Set the multiple property.

fileuploadObject.multiple=true|false

Property Values

Value Description
true|false Set whether more than one file can be selected with the file upload button
  • true - The file upload button accept multiple selection of files
  • false - Default. The file upload button does not accept multiple files




Return Value

A Boolean type value, true if more than one file can be selected with the file upload button, otherwise false.

Example

The following code shows how to set that the user can select multiple files.


<!DOCTYPE html>
<html>
<body>
<!-- w  w w .  j  av  a 2 s  .  c o m-->
<form action="url">
  Select files: <input type="file" id="myFile" name="files">
  <input type="submit">
</form>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
    document.getElementById("myFile").multiple = true;
    document.getElementById("demo").innerHTML = "changed";
}
</script>

</body>
</html>

The code above is rendered as follows:





Example 2

The following code shows how to check if a user can select more than one file with the file upload button.


<!DOCTYPE html>
<html>
<body>
<!--   w ww.  j  av a2  s  .  c o m-->
<form action="url">
  Select files: <input type="file" id="myFile" name="img" multiple>
  <input type="submit">
</form>
<button onclick="myFunction()">test</button>

<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("myFile").multiple;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows: