Skip to content

Commit

Permalink
Angular Forms In Depth
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Jan 7, 2021
1 parent bb95407 commit 00d9b65
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion src/app/file-upload/file-upload.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ export class FileUploadComponent {

fileName = '';

fileUploadError = false;

constructor(private http: HttpClient) {

}

onFileSelected(event) {

const file:File = event.target.files[0];
Expand All @@ -25,10 +31,37 @@ export class FileUploadComponent {

this.fileName = file.name;

console.log(this.fileName);
const formData = new FormData();

formData.append("thumbnail", file);

this.fileUploadError = false;

this.http.post("/api/thumbnail-upload", formData)
.pipe(
catchError(error => {
this.fileUploadError = true;
return of(error);
})
)
.subscribe();



}

}

}












0 comments on commit 00d9b65

Please sign in to comment.