Uncaught TypeError: Cannot read property ‘name’ of undefined

This type of error mean that your container variable fileis not defined.

You should use console.log at different places to see what is defined and what is not (your files array, etc.)

Also :

for(x=0;x<=this.files.length;x++)

Will be undefined for the last x value, because the last element of an array is at array.length - 1and not array.length, that gives you an undefined value at the end of your loop, probably the source of your error. In your case, x goes to the value this.files.length Also, always use var, otherwise your xwill be a global variable, which can be another source of problems.

A correct loop should be :

for (var x = 0; x < this.files.length; x++)

Leave a Comment