mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
debug image uploading
This commit is contained in:
@@ -234,10 +234,15 @@ var express = require('express'),
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
user.getUserField(req.user.uid, 'uploadedpicture', function(uploadedpicture) {
|
user.getUserField(req.user.uid, 'uploadedpicture', function(oldpicture) {
|
||||||
|
|
||||||
|
if(!oldpicture) {
|
||||||
|
uploadUserPicture(req.user.uid, req.files.userPhoto.name, req.files.userPhoto.path, res);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var index = uploadedpicture.lastIndexOf('/');
|
var index = oldpicture.lastIndexOf('/');
|
||||||
var filename = uploadedpicture.substr(index+1);
|
var filename = oldpicture.substr(index+1);
|
||||||
|
|
||||||
var absolutePath = global.configuration['ROOT_DIRECTORY'] + config.upload_path + filename;
|
var absolutePath = global.configuration['ROOT_DIRECTORY'] + config.upload_path + filename;
|
||||||
|
|
||||||
@@ -266,11 +271,14 @@ var express = require('express'),
|
|||||||
filename = uid + '-' + filename
|
filename = uid + '-' + filename
|
||||||
var uploadPath = config.upload_path + filename;
|
var uploadPath = config.upload_path + filename;
|
||||||
|
|
||||||
|
console.log('trying to upload to : '+ global.configuration['ROOT_DIRECTORY'] + uploadPath);
|
||||||
|
|
||||||
fs.rename(
|
fs.rename(
|
||||||
tempPath,
|
tempPath,
|
||||||
global.configuration['ROOT_DIRECTORY'] + uploadPath,
|
global.configuration['ROOT_DIRECTORY'] + uploadPath,
|
||||||
function(error) {
|
function(error) {
|
||||||
if(error) {
|
if(error) {
|
||||||
|
console.log(error);
|
||||||
res.send({
|
res.send({
|
||||||
error: 'Error uploading file!'
|
error: 'Error uploading file!'
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user