Skip to content

Commit

Permalink
fix problem in firefox with empty file upload
Browse files Browse the repository at this point in the history
  • Loading branch information
r3wt committed Jan 13, 2017
1 parent ae32f43 commit 10e90ff
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ module.exports = function(options) {
file.on('end', function() {
if (!req.files)
req.files = {};


// see: https://github.com/richardgirges/express-fileupload/issues/14
// firefox uploads empty file in case of cache miss when f5ing page.
// resulting in unexpected behavior. if there is no file data, the file is invalid.

if(!buf.length)
return;

return req.files[fieldname] = {
name: filename,
Expand All @@ -50,6 +58,8 @@ module.exports = function(options) {
});
}
};


});
});

Expand Down

0 comments on commit 10e90ff

Please sign in to comment.