Ad

Validations On Uploaded Files Using Jquery

- 1 answer

in the below JQuery code , i 'm validating the uploaded files :

        $(".inputFiles").on("change", function(e) {
        var uploadedFiles = e.originalEvent.target.files;
        var fileSize = 100;
        var fileType = ["image/jpeg", "image/pjpeg"];

        alert("length" + uploadedFiles.length)
        for (var i = 0,len = uploadedFiles.length; i < len; i++) {
            var n = uploadedFiles[i].name;
            var s = uploadedFiles[i].size; 
            var t = uploadedFiles[i].type;
        alert("size  "+uploadedFiles[i].s)

                        }
    });

});

it shows me size undefined in alert("size "+uploadedFiles[i].s) although in alert("length" + uploadedFiles.length) it's printing me the number of the uploaded files , so why i'm getting thisundefined

Ad

Answer

alert("size  "+uploadedFiles[i].s)

should be

alert("size  "+uploadedFiles[i].size)

or

alert("size  "+s)

Be sure to add server-side validation.

Ad
source: stackoverflow.com
Ad