Export (0) Print
Expand All
all
alt
ch
dir
id
min
rel
top
url
URL
urn
Expand Minimize
2 out of 2 rated this helpful - Rate this topic

files property

Returns a FileList object on a file type input object.

This property is read-only.

HTML5 A vocabulary and associated APIs for HTML and XHTML, Section 4.10.7.4Internet Explorer 10

Syntax

JavaScript
oFileList = object.files

Property values

Type: FileList

A FileList object containing a list of the files selected.

Standards information

Remarks

The following example lets you pick multiple files, and then displays them.


<!DOCTYPE html>
<html >
<head>
    <title>Files property test</title> 
    <script type="text/javascript">
        function getFiles() {
            // Get input element
            myFileList = document.getElementById("myfiles");
            // loop through files property, using length to get number of files chosen
            for (var i = 0; i < myFileList.files.length; i++) {
                // display them in the div
                document.getElementById("display").innerHTML += "<br/>" + myFileList.files[i].name ;
            }
        }
</script>
</head>
<body>
<label>Use <strong>shift</strong> or <strong>ctrl</strong> click to pick a few files: 
<input type="file" multiple id="myfiles" onchange="getFiles();" /></label>

<div id="display"></div>
</body>
</html>


See also

HTMLInputElement
input type=file

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.