-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Rails Example
guptapriyank edited this page Nov 14, 2014
·
17 revisions
Showing below is the upload code for controller in Angularjs
for (var i = 0; i < $files.length; i++) {
var file = $files[i];
$scope.upload = $upload.upload({
url: 'server/upload/url',
method: 'POST',
data: mydata,//it is the data that's need to be sent along with image
file: file,
fileFormDataName: 'myEntity[image]',//myEntity is the name of the entity in which image is saved and image is the name of the attachment
formDataAppender: function(fd, key, val) {
if (angular.isArray(val)) {
angular.forEach(val, function(v) {
fd.append('myEntity['+key+']', v);
});
} else {
fd.append('myEntity['+key+']', val);
}
}