Skip to content

Instantly share code, notes, and snippets.

@dileephell dileephell/gist:5011503
Last active Dec 14, 2015

Embed
What would you like to do?
var uuid=require('node-uuid');
var tmp_path = req.files.uploadimgs.path,uuid;
console.log(uuid);
// 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+uuid();
// 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');
});
});
};
its output is
22 Feb 12:47:53 - [nodemon] starting `node test.js`
server is working at "127.0.0.1:6000"
{ [Function: v4]
v1: [Function: v1],
v4: [Circular],
parse: [Function: parse],
unparse: [Function: unparse],
BufferClass:
{ [Function: Buffer]
poolSize: 8192,
isBuffer: [Function: isBuffer],
byteLength: [Function],
concat: [Function],
_charsWritten: 20 } }
cfgh
fdsggghggff
and in the work folder i m having the image with the name of "myImage.jpgc87fda2b-10ec-49eb-bc96-60d60f293098 "
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.