Reputation: 7656
I tried to upload and cropping using ng-file-upload.
The problem is the cropped image become base64 format instead of 'file` format.
Here is the console.log result on testing:
my html:
<div class="form-group">
<label class="control-label">Cover</label>
<input type="file" ngf-select ng-model="category.cover" name="cover" id="cover" ngf-pattern="image/*" accept="image/*"
ngf-max-size="512KB" class="filestyle" data-button-name="btn-danger">
<div ngf-drop ng-model="category.cover" ngf-pattern="image/*" class="cropAreaCover">
<img-crop image="category.cover | ngfDataUrl" result-image="category.croppedDataUrl" ng-init="category.croppedDataUrl=''"
area-type="square" area-min-size="800">
</img-crop>
</div>
</div>
How can I convert the cover result (base64) to file like logo result?
Upvotes: 2
Views: 1799
Reputation: 7656
I've found it using plain javascript syntax:
var cover =Upload.dataUrltoBlob(category.croppedDataUrl);
cover = new File([cover], 'cover.jpg', {type:"image/jpg"});
Upvotes: 5