Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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/' +;
// move the file from the temporary location to the intended location
fs.rename(tmp_path, target_path, function(err) {
if (err) throw err;
// 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;
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
You can’t perform that action at this time.