Skip to content

Commit

Permalink
Merge pull request #15 from r3wt/master
Browse files Browse the repository at this point in the history
fix problem  in firefox with empty file upload
  • Loading branch information
richardgirges authored Jan 13, 2017
2 parents ae32f43 + 10e90ff commit ec8087e
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 ec8087e

Please sign in to comment.