Q:

How can I change File.Name in dropzone before uploading

In the code below I have two controllers which is the upload/post and the document/post and it have small difficulty on saving file.name when it transfer on the API due to the seconds, sometimes the two not match for example the database one is file20170801053331.jpg the uploaded pic will be file20170801053332.jpg because of that the, two won't match so I was planning to transfer the filename to the upload controller so it will be the same but the file.name can't be changed.
   const req = request.post('http://localhost:8933/api/upload/post');
            acceptedFiles.forEach(file => {

                var now = new Date().toLocaleString('en-PH');
                form.State = 1;
                var cdate =dateFormat(now, "yyyymmddHHMMs")
                var ext = file.name.split(".").slice(-1)[0];
                var ext2 = file.name.split("."+ext).slice(0)[0];
                var fileNames = (ext2+cdate+"." +ext);
                form.Link=fileNames;
                form.Name=file.name;
                file.name = fileNames; // this is what im trying to do but it wasnt working  
                req.attach(file.name, file);
                this.props.post('document/post', form);
            });
                req.end(callback);

A:

you can change the file.name by adding the new name on the req.attach 
    var name =  form.something.length;
    var acceptedFiles = form.passFile;
    const req = request.post('http://localhost:8933/api/upload/post');
    acceptedFiles.forEach(file => {
        form.State = 1;
        var cdate =uuidv1();
        var ext = file.name.split(".").slice(-1)[0];
        var ext2 = file.name.split("."+ext).slice(0)[0];
        var fileNames = (ext2+cdate+"." +ext); // call this and put it on the req.attach
        form.Link=fileNames;
        form.Name=file.name;
        req.attach(file.name, file, fileNames);
        this.props.post('document/post', form);

    });

