The array .push()
method returns the length of the array after the element is added to the array, so you are changing the imgFileName
variable to hold the length of the array.
You could do:
var imgFileNames = [];
imgFileNames.push(escape(theFile.name));
And if you need to work with the file name:
var imgFileNames = [];
var fileName = escape(theFile.name);
imgFileNames.push(fileName);
Just to be clear though, you are not going to want to create the array every time right before you push a file name onto it. You will want to create it once.