Grouflon
Grouflon

Reputation: 57

blueimp fileupload with angularjs not uploading anything

I'm writing some tests trying to get the blueimp jquery-fileupload plugin working with angularjs.

Here is what I wrote, trying to keep it as simple as I could :

[controller.js]

app.controller('myAppController', function ($scope, uploadHandlerUrl) {
    $scope.options = {
        url: uploadHandlerUrl,
        add: function(e,data) {
            angular.element('#submit').click(function() {
                data.submit();
            });
        },
        done: function(e, data) {
            console.log('done', data);
        },
        progress: function(e,data) {
            console.log('progressing', data)
        }
    };
});;

[html]

<form id="fileupload" method="POST" enctype="multipart/form-data" data-fileupload="options">
    <input type="file" name="files[]" multiple="">
    <button id="submit">Submit</button>
</form>

You can also see a running instance here.

The problem is, every data object that is returned by the fileupload plugin seems to tell me that eveything went fine, but no files are actually uploaded on the server (the files should be uploaded here).

It may be caused by some configuration issue on my server, but I've absolutely no idea in which direction I should search. I'm using blueimp native uploadHandler.php on the server-side

Upvotes: 0

Views: 2768

Answers (1)

danial
danial

Reputation: 4098

This might save you hassle if you are looking for file upload using AngularJS

https://github.com/danialfarid/angular-file-upload

It is basically a directive like tosh's answer that takes care of non-HTML5 browsers with FileAPI flash polyfill and has $http.uploadFile function to upload the actual file via AJAX.

This issue Everything looks to be working, but no file in upload folder seems very similar to yours you can ask him how he fixed it.

Upvotes: 2

Related Questions