Guest User

Untitled

a guest
Jun 18th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.82 KB | None | 0 0
  1. Response data: {"status":500,"error":null}
  2.  
  3. <div ng-controller="sendEmailController">
  4. <div class="col-sm-1">
  5. <button class="btn btn-primary" type="button"
  6. ng-click="saveForm()">Send</button>
  7. </div>
  8. </div>
  9. </div>
  10. </div>
  11.  
  12. <div class="modal-body">
  13. <div class="row" >
  14. <input type="email" style="alignment: right" autofocus
  15. name="fromEmail" ng-model="fromEmail"></inputtext>
  16. </div>
  17. <div class="row">
  18. <input type="email" name="ccEmail"
  19. ng-model="ccEmail"></inputtext>
  20. </div>
  21. <div class="row">
  22. <input type="text" name="subject" ng-model="subject"></inputtext>
  23. </div>
  24. <div class="row">
  25. <input type="file" id="file" file-model="uploadedFile" name="file" multiple onchange="angular.element(this).scope().getFileDetails(this)"/>
  26. </div>
  27. <div class="row" >
  28. <label style="color: #0099ff;">Message: </label>
  29. <textarea rows="20" maxlength=35000
  30. background-color = grey; name="message"
  31. ng-model="message" >
  32. </textarea>
  33. </div>
  34. </div></div>
  35.  
  36. app.controller('sendEmailController', function ($rootScope, $scope, $uibModalInstance, MyService) {
  37. //get the file information
  38. $scope.getFileDetails = function (e) {
  39. alert("in get file details");
  40. $scope.files = [];
  41. $scope.$apply(function () {
  42. // STORE THE FILE OBJECT IN AN ARRAY.
  43. for (var i = 0; i < e.files.length; i++) {
  44. $scope.files.push(e.files[i])
  45. }
  46. });
  47. };
  48. $scope.saveForm = function () {
  49. var formData = new FormData();
  50. for (var i in $scope.files) {
  51. console.log("$scope.files[i] " + $scope.files[i]);
  52. formData.append("uploadfile", $scope.files[i]);
  53. }
  54. MyService.sendWithAttachments(formData).then( // $scope.fromEmail,$scope.ccEmail,$scope.subject,$scope.fileName,$scope.fileObj,$scope.message).then(
  55. function (response) {
  56. //response
  57. },
  58. function (errResponse) {
  59.  
  60. }
  61. );
  62. }
  63.  
  64. });
  65.  
  66. _repServiceFactory.sendWithAttachments = function (formData) {
  67.  
  68. var myUrl = appURL + '/sendData/sendEmailsTest.form';
  69. $http({
  70. method: "post",
  71. url: myUrl,
  72. //headers: {'Content-Type': 'application/x-www-form-urlencoded'},
  73. headers: {'Content-Type': undefined},
  74. data: formData
  75. /*transformRequest: function (data, headersGetterFunction) {
  76. return data;
  77. }*/
  78.  
  79. }).success(function (result) {
  80. console.log(result);
  81. });
  82. return deferred.promise;
  83. }
  84.  
  85. @Controller
  86. @RequestMapping("/sendData")
  87. public class DataController {
  88. @RequestMapping(value = "/sendEmailsTest", method = RequestMethod.POST)
  89. public
  90. @ResponseBody
  91. String sendEmailsTest(@RequestPart("file") List<MultipartFile> file) throws Exception {
  92.  
  93. System.out.println("request body form data " + file);
  94. //logic to get the files and the information and do accordingly..
  95. }
  96. }
  97.  
  98. <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  99. <property name="viewClass"
  100. value="org.springframework.web.servlet.view.JstlView" />
  101. <property name="prefix">
  102. <value>/WEB-INF/views/</value>
  103. </property>
  104. <property name="suffix">
  105. <value>.jsp</value>
  106. </property>
  107. </bean>
  108.  
  109. <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
  110. <property name="maxUploadSize" value="10000000"/>
  111. </bean>
Add Comment
Please, Sign In to add comment