cstefanache / angular2-img-cropper

Angular 2 Image Cropper
MIT License
364 stars 135 forks source link

Upload cropped image #189

Closed kenadet closed 7 years ago

kenadet commented 7 years ago

I want to upload my cropped image in a file like this:

let input = new FormData();
input.append('file', fileToUpload, this.user.email);

return this.api.postFile ('/profile/upload', input).subscribe(
            res => console.log(res.detailedResult),
            err => console.log(err)
 );

Is that possible, to get the cropped data and upload the cropped data as a file?

cstefanache commented 7 years ago

The output of the image cropper is a base64 encoded version. There might be the possibility to use https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileEntry but I really will leave this responsibility to the server

kenadet commented 7 years ago

Thanks, I took it in as a string and decoded it on the server as you rightly said. Appreciate.

cstefanache commented 7 years ago

thanks