Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. AnglarJs and NodeJs, Javascript, Directory/ creating folder | how to create folder/directory with auto generated id/name for each and every folder in AngularJs?

AnglarJs and NodeJs, Javascript, Directory/ creating folder | how to create folder/directory with auto generated id/name for each and every folder in AngularJs?

Scheduled Pinned Locked Moved JavaScript
javascriptsysadminjsonhelptutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 11627379
    wrote on last edited by
    #1

    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);
    });

    L 1 Reply Last reply
    0
    • U User 11627379

      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);
      });

      L Offline
      L Offline
      Leng Vang
      wrote on last edited by
      #2

      You didn't mention what language you are using on your server side, but it is your server side code that should handle those requirements. JavaScript or jquery has nothing to do with it.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups