mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 22:15:48 +01:00
moar refactor
This commit is contained in:
@@ -120,19 +120,9 @@ var nconf = require('nconf'),
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var tempPath = req.files.userPhoto.path;
|
var filename = 'category-' + params.cid + path.extname(req.files.userPhoto.name);
|
||||||
var extension = path.extname(req.files.userPhoto.name);
|
|
||||||
|
|
||||||
if (!extension) {
|
uploadImage(filename, req, res);
|
||||||
res.send({
|
|
||||||
error: 'Error uploading file! Error : Invalid extension!'
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var filename = 'category-' + params.cid + extension;
|
|
||||||
|
|
||||||
uploadImage(filename, tempPath, res);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post('/uploadfavicon', function(req, res) {
|
app.post('/uploadfavicon', function(req, res) {
|
||||||
@@ -148,17 +138,7 @@ var nconf = require('nconf'),
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var tempPath = req.files.userPhoto.path;
|
uploadImage('favicon.ico', req, res);
|
||||||
var extension = path.extname(req.files.userPhoto.name);
|
|
||||||
|
|
||||||
if (!extension) {
|
|
||||||
res.send({
|
|
||||||
error: 'Error uploading file! Error : Invalid extension!'
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
uploadImage('favicon.ico', tempPath, res);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post('/uploadlogo', function(req, res) {
|
app.post('/uploadlogo', function(req, res) {
|
||||||
@@ -175,6 +155,14 @@ var nconf = require('nconf'),
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var filename = 'site-logo' + path.extname(req.files.userPhoto.name);
|
||||||
|
|
||||||
|
uploadImage(filename, req, res);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function uploadImage(filename, req, res) {
|
||||||
|
|
||||||
var tempPath = req.files.userPhoto.path;
|
var tempPath = req.files.userPhoto.path;
|
||||||
var extension = path.extname(req.files.userPhoto.name);
|
var extension = path.extname(req.files.userPhoto.name);
|
||||||
|
|
||||||
@@ -185,13 +173,6 @@ var nconf = require('nconf'),
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var filename = 'site-logo' + extension;
|
|
||||||
|
|
||||||
uploadImage(filename, tempPath, res);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function uploadImage(filename, tempPath, res) {
|
|
||||||
var uploadPath = path.join(nconf.get('base_dir'), nconf.get('upload_path'), filename);
|
var uploadPath = path.join(nconf.get('base_dir'), nconf.get('upload_path'), filename);
|
||||||
|
|
||||||
winston.info('Attempting upload to: ' + uploadPath);
|
winston.info('Attempting upload to: ' + uploadPath);
|
||||||
|
|||||||
Reference in New Issue
Block a user