AnglarJs and NodeJs, Javascript, Directory/ creating folder | how to create folder/directory with auto generated id/name for each and every folder in AngularJs?
-
how to create folder/directory with auto generated id/name for each and every folder in AngularJs? i want to create folder/directory automatically, whenever the user upload his/her image file from their system. it should saved in server system in particular folder which should created automatically for each and every uploads with auto generated ID/ name for folders with in my parent folder called "upload". well am okay with Javascript code also, but it could be if it is in AngularJs if it is possible means. please share the codes. help will appreciated greatly.. the following is my code.
router.post('/photo',[ multer(
{
dest:'./uploads/',
rename: function (fieldname, filename, req, res) {
console.log(fieldname);
console.log("=============");
// console.log(req.body.can);
console.log("=============");console.log(filename); //return filename.replace(/\\W+/g, '-').toLowerCase() + Date.now() return filename }, onFileUploadComplete: function (file, req, res) { console.log(file.fieldname + ' uploaded to ' + file.path) // res.json({"responseCode":1}); }, changeDest: function(dest, req, res) { dest += '/uploads'+req.body.can; if (!fs.existsSync(dest)) fs.mkdirSync(dest); return dest; }
})
]);
router.post('/photo', function (req, res) {
id : req.body.can
//console.log(req.body.can)
//;return;
var form = {
body: req.body,
files: req.files
}
res.send(form);
}); -
how to create folder/directory with auto generated id/name for each and every folder in AngularJs? i want to create folder/directory automatically, whenever the user upload his/her image file from their system. it should saved in server system in particular folder which should created automatically for each and every uploads with auto generated ID/ name for folders with in my parent folder called "upload". well am okay with Javascript code also, but it could be if it is in AngularJs if it is possible means. please share the codes. help will appreciated greatly.. the following is my code.
router.post('/photo',[ multer(
{
dest:'./uploads/',
rename: function (fieldname, filename, req, res) {
console.log(fieldname);
console.log("=============");
// console.log(req.body.can);
console.log("=============");console.log(filename); //return filename.replace(/\\W+/g, '-').toLowerCase() + Date.now() return filename }, onFileUploadComplete: function (file, req, res) { console.log(file.fieldname + ' uploaded to ' + file.path) // res.json({"responseCode":1}); }, changeDest: function(dest, req, res) { dest += '/uploads'+req.body.can; if (!fs.existsSync(dest)) fs.mkdirSync(dest); return dest; }
})
]);
router.post('/photo', function (req, res) {
id : req.body.can
//console.log(req.body.can)
//;return;
var form = {
body: req.body,
files: req.files
}
res.send(form);
});