Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Response data: {"status":500,"error":null}
- <div ng-controller="sendEmailController">
- <div class="col-sm-1">
- <button class="btn btn-primary" type="button"
- ng-click="saveForm()">Send</button>
- </div>
- </div>
- </div>
- </div>
- <div class="modal-body">
- <div class="row" >
- <input type="email" style="alignment: right" autofocus
- name="fromEmail" ng-model="fromEmail"></inputtext>
- </div>
- <div class="row">
- <input type="email" name="ccEmail"
- ng-model="ccEmail"></inputtext>
- </div>
- <div class="row">
- <input type="text" name="subject" ng-model="subject"></inputtext>
- </div>
- <div class="row">
- <input type="file" id="file" file-model="uploadedFile" name="file" multiple onchange="angular.element(this).scope().getFileDetails(this)"/>
- </div>
- <div class="row" >
- <label style="color: #0099ff;">Message: </label>
- <textarea rows="20" maxlength=35000
- background-color = grey; name="message"
- ng-model="message" >
- </textarea>
- </div>
- </div></div>
- app.controller('sendEmailController', function ($rootScope, $scope, $uibModalInstance, MyService) {
- //get the file information
- $scope.getFileDetails = function (e) {
- alert("in get file details");
- $scope.files = [];
- $scope.$apply(function () {
- // STORE THE FILE OBJECT IN AN ARRAY.
- for (var i = 0; i < e.files.length; i++) {
- $scope.files.push(e.files[i])
- }
- });
- };
- $scope.saveForm = function () {
- var formData = new FormData();
- for (var i in $scope.files) {
- console.log("$scope.files[i] " + $scope.files[i]);
- formData.append("uploadfile", $scope.files[i]);
- }
- MyService.sendWithAttachments(formData).then( // $scope.fromEmail,$scope.ccEmail,$scope.subject,$scope.fileName,$scope.fileObj,$scope.message).then(
- function (response) {
- //response
- },
- function (errResponse) {
- }
- );
- }
- });
- _repServiceFactory.sendWithAttachments = function (formData) {
- var myUrl = appURL + '/sendData/sendEmailsTest.form';
- $http({
- method: "post",
- url: myUrl,
- //headers: {'Content-Type': 'application/x-www-form-urlencoded'},
- headers: {'Content-Type': undefined},
- data: formData
- /*transformRequest: function (data, headersGetterFunction) {
- return data;
- }*/
- }).success(function (result) {
- console.log(result);
- });
- return deferred.promise;
- }
- @Controller
- @RequestMapping("/sendData")
- public class DataController {
- @RequestMapping(value = "/sendEmailsTest", method = RequestMethod.POST)
- public
- @ResponseBody
- String sendEmailsTest(@RequestPart("file") List<MultipartFile> file) throws Exception {
- System.out.println("request body form data " + file);
- //logic to get the files and the information and do accordingly..
- }
- }
- <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
- <property name="viewClass"
- value="org.springframework.web.servlet.view.JstlView" />
- <property name="prefix">
- <value>/WEB-INF/views/</value>
- </property>
- <property name="suffix">
- <value>.jsp</value>
- </property>
- </bean>
- <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
- <property name="maxUploadSize" value="10000000"/>
- </bean>
Add Comment
Please, Sign In to add comment