Created
August 9, 2017 10:15
-
-
Save AndreasDickow/1ece5a164ed957ed753750c8abdc4f45 to your computer and use it in GitHub Desktop.
Angular2 Image Upload to Django Rest Framework
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let header = this._variableService.getToken(); | |
let input = new FormData(); | |
input.append("username", this.profileForm.controls['username'].value); | |
input.append("status", this.profileForm.controls['status'].value); | |
input.append("city", this.profileForm.controls['city'].value); | |
input.append("want_news", this.profileForm.controls['want_news'].value); | |
input.append("want_notifications", this.profileForm.controls['want_notifications'].value); | |
if (this.result !== null) { | |
console.log(this.result); | |
input.append("profile_image", this.result, this.result.name); | |
result = this.uploadService.upload(this._variableService.getBaseUrl() + '/api/v1/profile/' + this._variableService._userdetail.profile + '/', input, header); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment