Upload triggered from controller is not working
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)
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.
Using the selector is not working for me.
@junajan Thanks for posting this. Using the JQuery-Selector also helped me and worked just fine.
Thanks
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 ;)