Hi all,
In my case the file name should be same for every uploaded file means there will be only one image on that folder. If an image with same file name already exists then the new file is not uploaded and also i get uploadDone = true. My code is below:
var profilePicMulter = multer({
dest: './uploads',
rename: function (fieldname, filename) {
return "pic";
},
changeDest: function(dest, req, res) {
dest += req.query.picPath;
mkdirp(dest, function(err) {
if (err) console.log('Error creating directory ',err);
});
return dest;
},
onFileUploadStart: function (file) {
console.log(file.originalname + ' is starting ...')
},
onFileUploadComplete: function (file) {
console.log(file.fieldname + ' uploaded to ' + file.path)
uploadDone = true;
},
onError: function (error, next) {
console.log(error)
next(error)
}
});
Any help would be really appreciated. Thanks in advance!
Could you try with the latest version of multer? An 1.x release
Thanks updating to new version solved the problem :)
@LinusU do you mean if i upload a file and the same file name already exists in the folder, it should replace it ?
in my code i dont see the file is getting replaced
@LinusU do you mean if i upload a file and the same file name already exists in the folder, it should replace it ?
in my code i dont see the file is getting replaced
but i want it to be replaced. ;(((. So how do you do that?
Most helpful comment
but i want it to be replaced. ;(((. So how do you do that?