0

So I uploaded an image file and store it in a local folder, the assignment requirement is to move the image file from folder A to folder B, I have no clue to do this.

app.get('/fineupload003',function(req,res){

    function moveApprovedFile(file, uuid, success, failure) {
        var sourcePath = uploadedFilesPath;
        var desPath = 'approved';
        var desDir  = desPath + "/";
        var fileDes = desDir + file.name;

        fs.access()
    };
});
Phix
  • 8,460
  • 4
  • 32
  • 59

1 Answers1

0

If the requirements is to just move the file and not copy it, you could rename the file which would act as moving.

fs.rename(sourcePath, desPath);

Read more on rename: https://nodejs.org/docs/latest/api/fs.html#fs_fs_rename_oldpath_newpath_callback

Sarhad Salam
  • 390
  • 2
  • 12