From 01c9948e0c96226d9b75239da1b8e29f66fa8b5d Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 15 Jan 2020 16:26:48 +0100 Subject: [PATCH] Add rough profile picture upload --- src/app/components/profile/profile.component.html | 3 ++- src/app/components/profile/profile.component.ts | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/app/components/profile/profile.component.html b/src/app/components/profile/profile.component.html index f1f1e57..507a73d 100644 --- a/src/app/components/profile/profile.component.html +++ b/src/app/components/profile/profile.component.html @@ -3,9 +3,10 @@ -
+
camera_alt +
diff --git a/src/app/components/profile/profile.component.ts b/src/app/components/profile/profile.component.ts index ead215c..2811552 100644 --- a/src/app/components/profile/profile.component.ts +++ b/src/app/components/profile/profile.component.ts @@ -5,6 +5,7 @@ import { Levellist } from 'src/app/models/levellist'; import { RequestService } from 'src/app/services/request/request.service'; import { DatasharingService } from '../../services/datasharing.service'; import { ProfileService } from 'src/app/services/profile/profile.service'; +import { HttpClient } from '@angular/common/http'; @Component({ selector: 'app-profile', @@ -24,6 +25,7 @@ export class ProfileComponent implements OnInit { loading = false; constructor( + private http: HttpClient, private router: Router, private requestService: RequestService, private data: DatasharingService, @@ -65,4 +67,14 @@ export class ProfileComponent implements OnInit { user.allowedToSendRequest = false; this.requestService.sendFriendRequest(user); } + onFileInput(event) { + console.log(event.target.files[0]); + const formData: any = new FormData(); + formData.append('profilePicture', event.target.files[0]); + + this.http.post('https://greenvironment.net/upload', formData).subscribe( + (response) => console.log(response), + (error) => console.log(error) + ); + } }