X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Input FileUpload files Property

Input FileUpload Object Reference Input FileUpload Object

Example

Select one or more files with the file upload button, and display some information about the selected file(s):

var x = document.getElementById ("myFile");
var txt = "";
if ('files' in myFile) {
    if (x.files.length == 0) {
        txt = "Select one or more files.";
    } else {
        for (var i = 0; i < x.files.length; i++) {
            txt += "<br><strong>" + (i+1) + ". file</strong><br>";
            var file = x.files[i];
            if ('name' in file) {
                txt += "name: " + file.name + "<br>";
            }
            if ('size' in file) {
                txt += "size: " + file.size + " bytes <br>";
            }
        }
    }
}
document.getElementById ("demo").innerHTML = txt;

Try it yourself »


Definition and Usage

The files property returns a FileList object, representing the file or files selected with the file upload button.

Through the FileList object, you can get the the name, size and the contents of the files

This property is read-only.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The files property is supported in all major browsers.

Note: The files property is not supported in Internet Explorer 9 and earlier versions.


Syntax

fileuploadObject.files

Technical Details

Return Value: A FileList object that represents the selected file or files


Input FileUpload Object Reference Input FileUpload Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook