Вы можете сделать это следующим образом
HTML-код
<input type="file" (change)="onFileChanged($event)" #fileInput>
<button (click)="fileInput.click()">Select File</button>
<button (click)="onUpload()">Upload!</button>
Ts-код
import { HttpClient } from '@angular/common/http';
export class MyFileUploadComponent {
selectedFile: File;
constructor(private http: HttpClient) { }
onFileChanged(event) {
this.selectedFile = event.target.files[0]
}
onUpload() {
// make sure you have injected HttpClientModule in app.module.ts
this.http.post('my-backend.com/file-upload', this.selectedFile)
.subscribe(... something here..);
}
}