1

I have error with FormData in Angular 8. Error is "'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.invokeGetter" and get Empty array with this error.

I wondered if I have syntax error or logic error

My html

<form #f="ngForm" >
  <img *ngFor='let url of PhotoModels' [src]="url" height="200">
  <br/>
  <input type='file' #fileInput (change)="onSelectFile($event)" multiple>
  <button (click)="submit(f)" class="btn btn-success">save</button>
</form>

My Component

public PhotoModels = [];
@ViewChild('fileInput', { static: false }) fileInput:ElementRef

submit(f) {
  var PhotosElement: HTMLInputElement= this.fileInput.nativeElement
  this.PhotosService.Createphotos(PhotosElement.files)
}

My service

Createphotos(Photo) {
  let formData = new FormData();
  formData.forEach
  for(let i =0; i < Photo.length; i++){
    formData.append("Photos", Photo[i]);
  }
  console.log(formData)
}
SuleymanSah
  • 17,153
  • 5
  • 33
  • 54

1 Answers1

2

You cannot directly inspect formdata, For getting all files list, you need to use getAll function inside formdata object , like below. enter image description here

I'm able to run the code you attached, I didn't see any error in my console. Hope this helps you, Let me know still if you are facing an issue.

Allabakash
  • 1,969
  • 1
  • 9
  • 15