node.js - how to upload file from ng-controller? -


how can upload file angular controller. doing like, on ng-click calling upload_file() function declared inside controller. , want use

$http.post("url", data).success().error();  

url of node upload service. it's working fine when use . without using action there, want upload function.
not getting how attach file selected data here. want send data along file. can upload in way trying? please me...

you can use angular-file-upload library:

basically need $http.post this:

$http({                 method: 'post',                 url: config.url,                 headers: { 'content-type': false },                 transformrequest: function (data) {                     var formdata = new formdata();                       formdata.append('file', myfile);                     (key in mydata) {                         formdata.append(key, mydata[key]);                     }                     return formdata;                 }             }).success().error().progress() 

the library supports ie flash polyfill doesn't support formdata cannot file object <input file...>.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -