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

Upload triggered from controller is not working

Open junajan opened this issue 11 years ago • 5 comments

If you trigger upload from controller as it is shown in the Advanced example, firstly it will trigger undefined method to server. To fix that, you must add this line to the options: method: 'POST'

After that, upload function still ignores given file - I had to change your example to this to make it work:

HTML:

Upload function usage: upload({ url: '/api/advert', method:"POST", // added method data: { anint: 123, file: $("#myFile"), // specified DOM element or jquery object with DOM element } }).then( function (response) { alert(response.data); }, function (response) { alert(response.toSource()); } );

Please update your example..

(Using Firefox 29.0, Ubuntu Linux)

junajan avatar Jun 12 '14 13:06 junajan

Thanks so much @junajan for posting this issue! I can confirm that his method works, and that using ng-model and simply passing the scope variable through doesn't.

joonty avatar Nov 07 '14 10:11 joonty

Using the selector is not working for me.

rubinovitz avatar Feb 27 '15 21:02 rubinovitz

@junajan Thanks for posting this. Using the JQuery-Selector also helped me and worked just fine.

areindl avatar May 13 '15 09:05 areindl

Thanks

kendrikat avatar Oct 25 '15 20:10 kendrikat

If you are not using JQuery you need to wrap DOM element in angular element like this:

... file: angular.element(document.getElementById("uploadKeyFile")) ...

Otherwise it isn't working ;)

velja avatar Apr 18 '16 12:04 velja