lundi 18 juillet 2016

Getting file name for each file in javascript

I have this code which uploads multiple files through jQuery ajax method. So I want to check the size of each file and if it's above 1MB I want to output an error with the file name:

files = $("#att_form :input[type=file]").get(0).files;
for(i = 0; i < files.length; i++){
    fileSize = files[i].size;
    if(fileSize > 1024000){
        fileName = //I don't know how to get the file name
        outputError = "Your file "+fileName+" is larger than 1MB";
    }
}

So as You can see above, my problem is how to get the file name for each file larger than 1MB. pease anyone with an idea?

Aucun commentaire:

Enregistrer un commentaire