Multer does not save anything to me
See original GitHub issueHello,
here is my code I’m using on server side::
var uploader = multer({
dest: 'upload/',
filename: function (req, file, cb) {
console.log('>>>>>>>>>>>>>>>>>>>', file);
cb( null, file.fieldname + '-' + Date.now() );
}
});
var uploadHandler = function(req, res, next){
if( req.url !== '/system/upload' || req.method !== 'POST') return next();
uploader.array('x-files')( req, res, function( err ){
console.log('???????????????', err, req.files, req.file);
} );
};
...
.use( uploadHandler )
On client side vanilla javascript:
upload: function( url, files ){
var self = this;
var formData = new FormData();
formData.append( 'x-files', Array.isArray(files)?files:[files] );
var request = new XMLHttpRequest();
request.open('POST', url, true);
request.send( formData );
}
The line
console.log('???????????????', err, req.files, req.file);
works, I see ‘???’ on the screen but err, req.files, req.file are all undefined and the filename function is never called and nothing is stored in the folder upload
No error, yet no files are stored or set in the req object…
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Multer is grabbing images but it is not saving my files in the ...
I setup multer but for some reason it is not saving any of the photos that I want it to save locally so...
Read more >Express multer middleware
Multer is a node.js middleware for handling multipart/form-data , which is primarily used for uploading files. It is written on top of busboy...
Read more >File uploads using Node.js - CodeForGeek
Nice tutorial, but I'm trying to follow your steps and I'm not able to upload files. When I click the Upload button, the...
Read more >Multer Does Not Save File In The Folder - ADocLib
In this tutorial we are going to learn how to upload files on the server with Multer will not process any form which...
Read more >Upload Files from Multiple Fields using Multer | by Aakash Jha
When I started making the page to upload audiobooks — for the admin, i.e. me, I faced a challenge getting files from multiple...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This issue have now been dormant for >1 month, please answer the last instructions I posted to get more help 😃
Could you try the following code: