angular-upload icon indicating copy to clipboard operation
angular-upload copied to clipboard

Uploading again in IE fails

Open leon opened this issue 12 years ago • 10 comments

When pressing upload button it works the first time, but it will not upload the second time :(

leon avatar Oct 28 '13 13:10 leon

When moving the file input into the hidden form and back. the input's change event get's removed. To fix this we need to clone the input's events.

This isn't possible using jqLite, but I've submitted a pull request to angular, that will enable this.

https://github.com/angular/angular.js/pull/5141

If it gets merged, we can simply clone the element and it's events and it will fix this problem.

leon avatar Nov 26 '13 09:11 leon

Any update on this? :)

Update: or could you guide me on how to fix this issue by adding jquery as a dependency (jquery is in our project anyway)...

peeterslaurens avatar Aug 27 '14 12:08 peeterslaurens

@peeterslaurens was a while since I looked at this but. If I remember correctly, by adding jQuery it clones the element correctly and it just works.

If you cant get it working even though you have jQuery, post a comment and I'll have a look

leon avatar Aug 27 '14 12:08 leon

Jquery is in the project, yet it still does not work. I can 'mimic' the issue in chrome simply by setting the force-iframe-upload to true right?

Edit: Actually i can see it posting the request again, yet image i selected in the first iteration gets uploaded again and again :).

Edit 2: I can see the original element getting copied, but with every new upload, it's that same original element with the file I selected in the first iteration that's getting processed and uploaded. The other elements (for the 2nd, 3rd file-upload iteration) have no functionality :).

peeterslaurens avatar Aug 27 '14 13:08 peeterslaurens

So.. I fixed this bug, and it works in all browsers, by just removing the scope.$apply(function ...) and just calling scope.onUpload({ files: fileInput[0].files }); directly.

Why do we need the .$apply?

Izzmo avatar Jan 07 '15 05:01 Izzmo

I'm experiencing the same issue, but calling scope.onUpload does not fix it for me. Neither in ie9 nor in Chrome latest.

-scope.$apply(function () {
-    scope.onUpload({ files: fileInput[0].files });
-});
+scope.onUpload({ files: fileInput[0].files });

@Izzmo is this the diff you're using to fix it?

fantapop avatar Apr 02 '15 21:04 fantapop

oh, also, this would not apply to browser that don't use the file api such as IE 9

fantapop avatar Apr 02 '15 21:04 fantapop

@fantapop yep, and it's been working for me.

Izzmo avatar Apr 16 '15 00:04 Izzmo

by the way, I worked around this issue but adding an ng-if outside the element with the uploader on it cycling it false and then true again. This full resets the element. It works well.

fantapop avatar Apr 16 '15 05:04 fantapop

Example?

Izzmo avatar Apr 16 '15 12:04 Izzmo