javascript - Is it possible to upload multiple files using module "multiparty" in node? -


was using multiparty node module in node app uploading single file. now, want upload multiple files using same multiparty module.i googled not find solution , ended finding 'multer' module in link giving issue existing application. so, there way achieve uploading of file using 'multiparty' ?

after many failed attempts , experimentation got answer, have sent form object server client. have check of below code on server side

app.post('/multifileupload', function(req, res) {          var singlefile;              var form = new multiparty.form();         form.parse(req, function(err, fields, files){               var filearry=files.uploadfiles;                                        if(filearry == null ){                         res.send('no files found upload.');                             return;                      }                          for(i=0; i<filearry.length; i++)                         {                               newpath='./uploads/';                             singlefile=filearry[i];                             newpath+=singlefile.originalfilename;                             readandwritefile(singlefile,newpath);                                                }                         res.send("file uploaded to: " + newpath);                 });      });       function readandwritefile(singlefile , newpath){          fs.readfile(singlefile.path, (err, data)=>{             fs.writefile(newpath, data, (err)=>{                                                                                                                                     console.log("file uploaded  :"+newpath);                 });         });     } 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -