Input FileUpload multiple Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input FileUpload

Description

The multiple property sets or gets whether more than one file can be selected with the file upload button.

This property reflects the HTML multiple attribute.

Set the multiple property with the following Values

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

Return Value

A Boolean, returns true if more than one file can be selected with the file upload button, otherwise it returns false

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

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<form action="#">
  Select files: <input type="file" id="myFile" name="files">
  <input type="submit">
</form>/*  ww  w . ja  v a  2s .  c o  m*/

<button onclick="myFunction()">Test</button>

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

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

</body>
</html>

Related Tutorials