Upload file without using Multi Part form data using AngularJS

Posted By : Rahul Sarkar | 10-Jan-2017

Upload file without using Multi Part form data using AngularJS

Here I am going to describe you that how to Upload file without using Multipart form data in AngularJS, if you are new in AngularJS and you don't have knowledge about Multipart form data then this blog will help you a lot, you can upload your file using these very few simple steps:

First of all you need to write you HTML view part using an input type file.

Now you have to write your AngularJS code to get the file data from your HTML page:

 
    $scope.submitClientProfileDataCtrl = function() {
       var formData = new FormData();
       formData.append( 'attachment1', $scope.clientAttachment1); 
      // POST your data using http post method
      $http({
                method: "post",
                url: '/clientProfile/getClientProfileDetails/.json',// enter your own url
                data : formData,
                transformRequest: angular.identity,
                headers: {'Content-Type': undefined}
            }).then(function(data) {
            	console.log("success data ", data);
            }, 
            function(data) {
            	console.log("error data ", data); 
            });
    	};	  
 
Thanks,

About Author

Author Image
Rahul Sarkar

Rahul is an intellectual web app developer, he has good knowledge of C, Java, Java Script, Jquery. Apart from this he likes to travel and explore new places.

Request for Proposal

Name is required

Comment is required

Sending message..