angular 4- How do I send file in POST to backend
问题 I have a file upload in the form. I need to create post request to backend with this uploaded file and some other form fields too. Below is my code: fileChange(event) { const fileList: FileList = event.target.files; if (fileList.length > 0) { this.file = fileList[0]; this.form.get('file_upload').setValue(this.file); } } onClick(){ const val = this.form.value; const testData = { 'file_upload': this.file, 'id': val.id, 'name' : val.name, 'code': val.code, }; this.http.post('https://url',