【问题标题】:get file from html input and pass to c# function with angular [duplicate]从html输入获取文件并使用角度传递给c#函数[重复]
【发布时间】:2017-04-22 10:53:21
【问题描述】:

我想做这样的事情:

    //have the choose a pdf document from their local drive
    <html> 
        <input type="file" ng-model="theInputFile"/>
        <button ng-click="submit()"> Submit </button>
    </html>

    //pass the document to a c# function for parsing
    <script>
        $scope.submit = function(){
            $http.post('Home/GetVendorInfo', 
               { "c#Input": $scope.theInputFile})
            .success(function (response) {
               console.log("send successtul");
   });
    </script>

【问题讨论】:

    标签: angularjs html-input


    【解决方案1】:

    你应该有一个控制器和模块,

    var app = angular.module("app", []);
    app.controller("uploadController", ["$scope",
      function($scope) {    
     $scope.submit = function(){
                $http.post('Home/GetVendorInfo', 
                   { "c#Input": $scope.theInputFile})
         .success(function (response) {
         console.log("send succestul");
    }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-30
      相关资源
      最近更新 更多