JSFiddle - React, Tailwind, and code Playground
by chikunova_nata
JavaScript
this.uploadImage = function (url, file) {
var deferred = $q.defer();
var fd = new FormData();
fd.append('form[file]', file);
$http({
method: 'POST',
url: url,
data: fd,
withCredentials: true,
headers: {'Content-Type': undefined },
transformRequest: angular.identity
})
.success(function (data, status) {
deferred.resolve({success: true, data: data, status: status});
})
.error(function (data, status) {
deferred.resolve({success: false, data: data, status: status});
});
return deferred.promise;
};