相关疑难解决方法(0)

AngularJS:跟踪同时上传的每个文件的状态

在按下提交按钮,文件的数组($scope.files,可以少为一个文件,多达用户希望)通过被提交FormData,并XMLHttpRequest在我的角度功能$scope.uploadFiles:

$scope.uploadFiles = function() {
    for (var i in $scope.files) {
        var form = new FormData();
        var xhr = new XMLHttpRequest;

            // Additional POST variables required by the API script
        form.append('destination', 'workspace://SpacesStore/' + $scope.currentFolderUUID);
        form.append('contenttype', 'idocs:document');
        form.append('filename', $scope.files[i].name);
        form.append('filedata', $scope.files[i]);
        form.append('overwrite', false);

        xhr.upload.onprogress = function(e) {
            // Event listener for when the file is uploading
            $scope.$apply(function() {
                var percentCompleted;
                if (e.lengthComputable) {
                    percentCompleted = Math.round(e.loaded / e.total * 100);
                    if (percentCompleted < …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs

45
推荐指数
1
解决办法
2万
查看次数

AngularJS中的$ http上传文件进度

如何从上传图像的AngularJS $ http POST请求中获取"进度"事件?是否可以在客户端执行此操作,或者我是否需要服务器在接收数据时报告进度?

angularjs

25
推荐指数
3
解决办法
6万
查看次数

标签 统计

angularjs ×2

javascript ×1