The multiple
property sets or gets whether
more than one file can be selected.
multiple |
Yes | 10.0 | Yes | Yes | Yes |
Return the multiple property.
var v = fileuploadObject.multiple
Set the multiple property.
fileuploadObject.multiple=true|false
Value | Description |
---|---|
true|false | Set whether more than one file can be selected with the file upload button
|
A Boolean type value, true if more than one file can be selected with the file upload button, otherwise false.
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:
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: