From b962972d216d09f9a15f5b3af9041e7263fbf933 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Wed, 19 Jun 2013 09:47:15 -0400 Subject: [PATCH] changed the image upload to use the path module instead of / --- src/routes/user.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/routes/user.js b/src/routes/user.js index c246bfd061..5cf6981714 100644 --- a/src/routes/user.js +++ b/src/routes/user.js @@ -2,6 +2,7 @@ var user = require('./../user.js'), fs = require('fs'), utils = require('./../../public/src/utils.js'), + path = require('path'), marked = require('marked'); (function(User) { @@ -112,9 +113,7 @@ var user = require('./../user.js'), return; } - var index = oldpicture.lastIndexOf('/'); - var filename = oldpicture.substr(index + 1); - + var filename = path.basename(oldpicture); var absolutePath = global.configuration['ROOT_DIRECTORY'] + config.upload_path + filename; fs.unlink(absolutePath, function(err) { @@ -141,14 +140,13 @@ var user = require('./../user.js'), filename = uid + '-' + filename; var uploadPath = config.upload_path + filename; - console.log(config); console.log('trying to upload to : '+ global.configuration['ROOT_DIRECTORY'] + uploadPath); var is = fs.createReadStream(tempPath); var os = fs.createWriteStream(global.configuration['ROOT_DIRECTORY'] + uploadPath); - is.on('end', function(){ + is.on('end', function() { fs.unlinkSync(tempPath); var imageUrl = config.upload_url + filename;