media.html
<form #form="ngForm" (ngSubmit)="uploadFile(form.value)">
<input type="file" ngControl="inputFile" />
<input type="text" ngControl="name"/>
<button type="submit" >Upload</button>
</form>
media.ts
uploadFile(fileInput){
console.log(fileInput); // this
this.mediaService.addMedia(fileInput).subscribe((response)=> {
console.log(response);
},
(error) => {
console.log(error.text());
}
);
}
when I try to access the file input in line : console.log("fileInput");, it prints out:
inputFile:null
name: "asdasdasdasd"
This indicates that I am unable to retrieve the value of inputFile to send it to my server. Any advice on how to successfully capture it would be greatly appreciated. Thank you for your help!