Answer the question
In order to leave comments, you need to log in
How to correctly organize file upload through a form in NodeJs?
There are many places where such a file upload to the server is described.
var fs = require('fs');
router.post( '/api/upload/avatar', function( req, res ) {
var File = fs.createWriteStream( "newimage.jpg");
req.pipe( File );
})
Answer the question
In order to leave comments, you need to log in
For the sake of Allah, take the multiparty library, there can also be many files in one form and many files even in one file field. There is a complex format, MIME, you can't just write everything to the stream. All this needs to be parsed https://www.npmjs.com/package/multiparty examples are there.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question