|
|
@ -55,7 +55,7 @@ function upload(req, res, filesIterator, next) {
|
|
|
|
function uploadPost(req, res, next) {
|
|
|
|
function uploadPost(req, res, next) {
|
|
|
|
upload(req, res, function(file, next) {
|
|
|
|
upload(req, res, function(file, next) {
|
|
|
|
if(file.type.match(/image./)) {
|
|
|
|
if(file.type.match(/image./)) {
|
|
|
|
uploadImage(file, next);
|
|
|
|
uploadImage(req.user.uid, file, next);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
uploadFile(file, next);
|
|
|
|
uploadFile(file, next);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -75,7 +75,7 @@ function uploadThumb(req, res, next) {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
return next(err);
|
|
|
|
return next(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
uploadImage(file, next);
|
|
|
|
uploadImage(req.user.uid, file, next);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
next(new Error('[[error:invalid-file]]'));
|
|
|
|
next(new Error('[[error:invalid-file]]'));
|
|
|
@ -84,22 +84,22 @@ function uploadThumb(req, res, next) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function uploadImage(image, callback) {
|
|
|
|
function uploadImage(uid, image, callback) {
|
|
|
|
if (plugins.hasListeners('filter:uploadImage')) {
|
|
|
|
if (plugins.hasListeners('filter:uploadImage')) {
|
|
|
|
plugins.fireHook('filter:uploadImage', image, callback);
|
|
|
|
plugins.fireHook('filter:uploadImage', {image: image, uid: uid}, callback);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
if (parseInt(meta.config.allowFileUploads, 10)) {
|
|
|
|
if (parseInt(meta.config.allowFileUploads, 10)) {
|
|
|
|
uploadFile(image, callback);
|
|
|
|
uploadFile(uid, image, callback);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
callback(new Error('[[error:uploads-are-disabled]]'));
|
|
|
|
callback(new Error('[[error:uploads-are-disabled]]'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function uploadFile(file, callback) {
|
|
|
|
function uploadFile(uid, file, callback) {
|
|
|
|
if (plugins.hasListeners('filter:uploadFile')) {
|
|
|
|
if (plugins.hasListeners('filter:uploadFile')) {
|
|
|
|
plugins.fireHook('filter:uploadFile', file, callback);
|
|
|
|
plugins.fireHook('filter:uploadFile', {file: file, uid: uid}, callback);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
if(parseInt(meta.config.allowFileUploads, 10) !== 1) {
|
|
|
|
if(parseInt(meta.config.allowFileUploads, 10) !== 1) {
|
|
|
|