2

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
  • 9,364
  • 4
  • 35
  • 62
Yiting Liu
  • 23
  • 1
  • 3

1 Answers1

3

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
  • 428
  • 3
  • 12