diff --git a/lib/uploadhandler.js b/lib/uploadhandler.js index 070f018..bc37fed 100644 --- a/lib/uploadhandler.js +++ b/lib/uploadhandler.js @@ -142,6 +142,13 @@ module.exports = function (options) { generatePreviews(); finish(); } else { + if (err.code === 'ENOTDIR') { + // Tried to rename to a path inside a file + fs.unlink(file.path); + self.emit('error', err); + return; + } + var is = fs.createReadStream(file.path); var os = fs.createWriteStream(options.uploadDir() + '/' + fileInfo.name); is.on('end', function (err) {