v1.18.x
barisusakli 9 years ago
parent 7c2041e8d8
commit cf00371892

@ -46,15 +46,9 @@ uploadsController.upload = function(req, res, filesIterator, next) {
uploadsController.uploadPost = function(req, res, next) {
uploadsController.upload(req, res, function(uploadedFile, next) {
if (uploadedFile.type.match(/image./)) {
file.isFileTypeAllowed(uploadedFile.path, function(err, tempPath) {
if (err) {
return next(err);
}
uploadImage(req.user ? req.user.uid : 0, uploadedFile, next);
});
uploadImage(req.uid, uploadedFile, next);
} else {
uploadFile(req.user ? req.user.uid : 0, uploadedFile, next);
uploadFile(req.uid, uploadedFile, next);
}
}, next);
};
@ -82,7 +76,7 @@ uploadsController.uploadThumb = function(req, res, next) {
if (err) {
return next(err);
}
uploadImage(req.user ? req.user.uid : 0, uploadedFile, next);
uploadImage(req.uid, uploadedFile, next);
});
} else {
next(new Error('[[error:invalid-file]]'));
@ -108,11 +102,16 @@ function uploadImage(uid, image, callback) {
return plugins.fireHook('filter:uploadImage', {image: image, uid: uid}, callback);
}
if (parseInt(meta.config.allowFileUploads, 10)) {
uploadFile(uid, image, callback);
} else {
callback(new Error('[[error:uploads-are-disabled]]'));
}
file.isFileTypeAllowed(image.path, function(err, tempPath) {
if (err) {
return callback(err);
}
if (parseInt(meta.config.allowFileUploads, 10)) {
uploadFile(uid, image, callback);
} else {
callback(new Error('[[error:uploads-are-disabled]]'));
}
});
}
function uploadFile(uid, uploadedFile, callback) {

Loading…
Cancel
Save