Skip to content

Instantly share code, notes, and snippets.

@kamiyam
Created September 26, 2014 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kamiyam/b48d477f900814101cd8 to your computer and use it in GitHub Desktop.
Save kamiyam/b48d477f900814101cd8 to your computer and use it in GitHub Desktop.
File Upload form data multiple for Angular
do(d=document)->
app = angular.module myApp, []
app.controller "uploadCtrl", ["$scope", "$http", ($scope, $http)->
$scope.$data = {
userId: "ID"
userName: "USER_NAME"
userMail: "sample@example.com"
receiveMail: "sample@example.com"
downloadPassword: "hogehoge"
}
$scope.$fn = {}
$scope.$fn.fileUpload = ()->
data = {
user_id: $scope.$data.userId
user_name: $scope.$data.userName
user_mail: $scope.$data.userMail
receive_mail: $scope.$data.receiveMail
download_password: $scope.$data.downloadPassword
}
fd = new FormData( angular.element("#form1")[0]);
$http({
method: "POST"
url: "/file/upload"
data: fd
params: data
transformRequest: angular.identity
headers: {'Content-Type': undefined}
})
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment