如何使用AngularJs上传kendo文件?

时间:2015-06-28 22:29:51

标签: angularjs file-upload kendo-ui

我正在使用我将使用Restfull Post请求发送到服务器的angularjs的kendo文件上传,下面的代码我无法使用kendo AngularJs上传文件任何帮助将不胜感激。

main.html

<div class="row">
    <div class="form-group col-md-12 fieldHeight">
        <label for="issueNo" class="col-md-4">File name:</label>
        <div class="col-md-6">
            <input name="files"
               type="file"
               kendo-upload
               k-async="{ saveUrl: 'http://www.google.com', removeUrl: 'remove', autoUpload: false }"
               k-select="onSelect"
             />
        </div>
        <div class="col-md-2">
            <button class="btn btn-primary pull-right" ng-disabled="addRiskForm.$invalid" ng-click="browse()">Browse</button>
        </div>
    </div>
</div>

main.js

  $scope.$on('addDocument', function (s,id){
    $scope.riskAssessmentDTO.riskAssessmentKey = id;
    $scope.viewDocumentWin.open().center();
  });

  $scope.onSelect = function(e) {
    var message = $.map(e.files, function(file) { return file.name; }).join(", ");
    console.log(message);
}

1 个答案:

答案 0 :(得分:0)

您没有从您的控件中调用任何WEB API类。 你的代码:

k-async="{ saveUrl: 'http://www.google.com', removeUrl: 'remove', autoUpload: false }"

应该看起来像:

k-async="{ saveUrl: '/upload/save', removeUrl: '/upload/remove', autoUpload: true }""