0

I would like to upload one file at a time, while allowing multiple files to be dragged/selected at once. Is there a way to do this? It seems that using a promise might be the way to go, but, having never used promises before, I am not sure.

Right now, I have this code:

        for (var i = 0, len = $scope.files.length; i < len; i++)
        {
            var file = $scope.files[i];
            file.progress = 0;
            Upload.upload({
                url: '/file-upload',
                fields: {},
                file: file
            }).progress(function (e) {
                file.progress = parseInt(100.0 * e.loaded / e.total) + '%';
            }).success(function (data, status, headers, config) {
                file.progress = 100;
            });
        }

1 Answers1

1

File upload is a slow process, you don't want your browser to be frozen while the upload is in progress. Also angular does not support synchronous http calls: https://stackoverflow.com/a/13088385/1105011

Community
  • 1
  • 1
danial
  • 4,058
  • 2
  • 32
  • 39
  • I am facing some problems while uploading an array of images to the server. As the upload procedure is async all my files becomes corrupted as angular is sending second image to Web API before the first one's upload is completed... But when i upload only one image it works fine. do you have any suggestions? – khaled4vokalz Mar 13 '16 at 16:09