Question: I have an upload progress bar that works upon file input and when the bar reaches 100%, there is no error. But as I print the contents of the file in Spring Boot, I notice that the code within the for loop does not run. Here is the code. Please help and thank you!

JavaScript:

```
function upload(file) {
    var formData = new FormData();
    formData.append("newFile", file);
    var xhr = new XMLHttpRequest();
    xhr.open('POST', '/upload');
    xhr.onload = function(e) {
        console.log("xhr onload function");
    };
    var progressBar = document.querySelector('progress');
    xhr.upload.onprogress = function(e) {
        if (e.lengthComputable) {
            progressBar.value = (e.loaded / e.total) * 100;
            progressBar.textContext = progressBar.value;
        }
    };
    xhr.send(formData);
}

```

Spring Boot:

```
@RequestMapping(value="/upload", method=RequestMethod.POST)
public String upload(@RequestParam("files") MultipartFile[] files) {

    // This prints [Lorg.springframework.web.multipart.MultipartFile;@........].
    System.out.println(files);
    for (MultipartFile file : files) {
        // This doesn't get printed.
        System.out.println(file.getOriginalFilename());
    }
    return "redirect:/";
}

```

Answer: 
**Sample 1**

As mentioned in my comment, the first solution is to access the `update` property and invoke `push()` on it since you already defined `update` to contain an `Array` instance:

```
//starting loop
for ( i = 0; i < lastrow; i++){
   APIPayloadObject.update.push({
      id:   loopRange[i][0],
      name: loopRange[i][1]
   })
}

```

**Sample 2**

You can take it one step further and directly write your objects to `update` Array at the `i` index, since you start from 0:

```
//starting loop
for ( i = 0; i < lastrow; i++){
   APIPayloadObject.update[i] = {
      id:   loopRange[i][0],
      name: loopRange[i][1]
   };
}

```
This is a great use case for [Array.prototype.map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).

```js
// @param {sheetValues[][]} loopRange
function getPayload(loopRange) {
  return JSON.stringify({
    update: loopRange.map(function (row) {
      return {id: row[0], name: row[1]};
    })
  });
}

```