how to upload file using Angularjs, multipart/form-data

后端 未结 2 1393
感动是毒
感动是毒 2020-12-20 10:07

i want to upload image using Angularjs anyone know how do this..REST API wants

Content-Type:multipart/form-data

www.abc.         


        
2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-20 11:02

    I think you don't use $http the right way.

    You can use the headers attribute of the $http service, like this :

    $scope.UploadImage = function () { 
      var config = {
        headers: {      
          'Content-Type': 'multipart/form-data',
        }
      };
    
      $http({
        method: 'POST',
        url: properties.customerUploadImage_path + "/" + checkprofile,
        data: $scope.tempObject,
        config: config,
      }).success(function (response) { 
        console.log('Uploaded');
      });
    
    
    };
    

    I suggest you to take a look at the documentation.

提交回复
热议问题