I have a form in angular. I want to post the data in this form. There are 4 file uploads. How can I post the entire form together with the file.
export class TrackDetailComponent implements OnInit, AfterViewInit {
public data = new FormData();
constructor(
@Inject('TrackService') public trackService: ApiService<Track> ) {
}
handleFileInput(files: FileList, name) {
this.data.append(name, files.item(0));
}
saveOrCreate(valid) {
if (valid)
{
this.data.append('trackName', this.track.trackName);
this.data.append('trackPerformerId', this.track.trackPerformerId+ '');
this.data.append('trackGenreId', this.track.trackGenreId + '');
this.data.append('trackYear', this.track.trackYear + '');
//this.data.append('listDateTime', this.track.listDateTime.toLocaleString("en-US"));
this.data.append('fizyUrl', this.track.fizyUrl);
console.log(this.data);
console.log(this.track);
this.trackService.getService().all(this.trackService.getApiUrl()).post(this.data ).subscribe((data) => {
......