Skip to content

Random Code Snippets

Varun Patil edited this page Mar 15, 2018 · 1 revision

Upload Image

HTML

<input style="display:none;" type="file" accept="image/*" #file id="file" (change)="goimg($event.target.files)">
<button mat-raised-button (click)="file.click()">Upload file</button>

TS

goimg(files: FileList) {
  this.dataService.UploadImage(files[0]).subscribe(result => {
    console.log(result);
  });
}
Clone this wiki locally