i got a problem with the fs.rename function! Sometimes it doesn´t works and i don´t know why. I try to upload some files and rename it! So it should be work for a time. in the codes below:
exports.up = function(req, res){
var len = [].concat(req.files.fileSelect);
for(var i = 0; i < len.length; i++) {
var tmp_path =(len[i].path);
if(len[i].name ==''){
len[i].name ='empty';
}
console.log(len[i]);
var target_path =('./public/images/' + len[i].name);
fs.rename(tmp_path, target_path, function(err) {
if (err) throw err;
fs.unlink(tmp_path, function() {
if (err) throw err;
});
});
}
res.redirect('/picture');
};