Skip to content

Instantly share code, notes, and snippets.

@dileephell
Created February 22, 2013 06:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dileephell/5011281 to your computer and use it in GitHub Desktop.
Save dileephell/5011281 to your computer and use it in GitHub Desktop.
var tmp_path = req.files.uploadimgs.path;
// set where the file should actually exists - in this case it is in the "images" directory
var target_path = './upload/work/' + req.files.uploadimgs.name;
// move the file from the temporary location to the intended location
fs.rename(tmp_path, target_path, function(err) {
if (err) throw err;
console.log('cfgh');
// delete the temporary file, so that the explicitly set temporary upload dir does not get filled with unwanted files
fs.unlink(tmp_path, function() {
if (err) throw err;
console.log('fdsggghggff');
res.send('File uploaded to: ' + target_path + ' - ' + req.files.uploadimgs.size + ' bytes');
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment