Reputation: 23
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()
};
});
Upvotes: 2
Views: 4872
Reputation: 438
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
Upvotes: 3