Skip to content

Instantly share code, notes, and snippets.

@AndreasDickow
Created August 9, 2017 10:15
Show Gist options
  • Save AndreasDickow/1ece5a164ed957ed753750c8abdc4f45 to your computer and use it in GitHub Desktop.
Save AndreasDickow/1ece5a164ed957ed753750c8abdc4f45 to your computer and use it in GitHub Desktop.
Angular2 Image Upload to Django Rest Framework
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