From 9b54ce7235bd9a5db9b5b16127aa03c37c4921ee Mon Sep 17 00:00:00 2001 From: barisusakli Date: Tue, 3 May 2016 16:14:41 +0300 Subject: [PATCH] fix uploads with no extensions --- src/controllers/uploads.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/controllers/uploads.js b/src/controllers/uploads.js index 223f7818a1..d096ecf0de 100644 --- a/src/controllers/uploads.js +++ b/src/controllers/uploads.js @@ -185,6 +185,9 @@ function uploadFile(uid, uploadedFile, callback) { if (meta.config.hasOwnProperty('allowedFileExtensions')) { var allowed = file.allowedExtensions(); var extension = path.extname(uploadedFile.name); + if (!extension) { + extension = '.' + mime.extension(uploadedFile.type); + } if (allowed.length > 0 && allowed.indexOf(extension) === -1) { return callback(new Error('[[error:invalid-file-type, ' + allowed.join(', ') + ']]')); } @@ -195,7 +198,7 @@ function uploadFile(uid, uploadedFile, callback) { function saveFileToLocal(uploadedFile, callback) { var extension = path.extname(uploadedFile.name); - if(!extension) { + if (!extension) { extension = '.' + mime.extension(uploadedFile.type); }