javascript - angular - Submit form by controller -


i want submit form controller function. have following code :-

<form ng-submit="uploadlogo()" name="logoform" method="post" enctype="multipart/form-data">  <div class="col-sm-6">   <input type="file" name="letterhead" id="letterhead" required />      <div>                                                   <button type="submit" class="btn btn-md btn-info">upload</button> </div>  </form> 

controller

$scope.uploadlogo = function () {         practices.updatelogo().save(function (res) {             console.log('res :' + res);         });      } 

service

updatelogo: function () {               return $resource('/api/practicesupload',                   {}, { 'save': { method: 'post'} });           } 

routes

 app.post('/api/practicesupload', multipartmiddleware, practices.uploadlogo); 

server side

exports.uploadlogo = function (req, res, next) {     console.log('called');     console.log(req.files);     var tempfile = req.files.letterhead.path;     .... } 

the server side gets called don't files. error typeerror: cannot read property 'path' of undefined doesn't exist.

if directly submit form, works :-

<form action="/api/practicesupload" name="logoform" method="post" enctype="multipart/form-data"> 

how submit form controller. reason me submit controller show success message creating flag in controller.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -