It's about two days I'm trying to upload images using Nodejs and Expressjs (4.0).
I tryed several middlewares so far, like: Formidable, Blueimp, Busboy, Multer...
With few of these I correctly saved a single image on a temporary folder but the problems comes when I try to upload multiple images.
So, my simple controller look like:
exports.postAccountImages = function(req, res, next) {
User.findById(req.user.id, function(err, user) {
console.log(req.files);
});
};
What I receive is always single Objects like:
{
files: {
// data...
}
}
{
files: {
// data...
}
}
But are not inside an array, so I can not manage all the files incoming using for.
I need to change the name to the images and save these on dynamic folder based on user.id name... but it seems to be too tricky.
I can do it one by one, but I wish to do that on multiple images.
Do you know a middleware or how to use correctly one of the ones I already tried to manage multiple files?
EDIT:
I used Dragzone for the client side. Nothing special here, followed the initial tutorial:
Jade:
#uploader.fileInput
h3 Drop your images here!
Js:
var myDropzone = new Dropzone(document.body, {
url: "/account/images", // Set the url
autoQueue: true,
paramName: "file",
uploadMultiple: true,
autoProcessQueue: true,
clickable: ".fileInput"
});