Javascript DOM HTML Input FileUpload multiple Property get

Input FileUpload multiple Property

Find out if a user can select more than one file with the file upload button:

var x = document.getElementById("myFile").multiple;

Click button to find out if the file upload button accept multiple files.

View in separate window

<!DOCTYPE html>
<html>
<body>

<form action="/action_page.php">
  Select files: <input type="file" id="myFile" name="img" multiple>
  <input type="submit">
</form>//  w  ww  . j  a  va  2s  . c  o  m

<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 multiple property sets or gets whether user can select more than one file with the file upload button.

true value allows the user to select more than one file.

This property mirrors the HTML multiple attribute.

To select multiple files, hold down the CTRL or SHIFT key while selecting.

The multiple property accepts and returns a boolean type value.

Property Values

Value Description
trueThe file upload button accept multiple selection of files
false Default. The file upload button does not accept multiple files

The multiple property returns true if more than one file can be selected with the file upload button, otherwise it returns false.




PreviousNext

Related