Skip to content

Commit 10e90ff

Browse files
committed
fix problem in firefox with empty file upload
1 parent ae32f43 commit 10e90ff

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/index.js

+10
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ module.exports = function(options) {
3232
file.on('end', function() {
3333
if (!req.files)
3434
req.files = {};
35+
36+
37+
// see: https://github.com/richardgirges/express-fileupload/issues/14
38+
// firefox uploads empty file in case of cache miss when f5ing page.
39+
// resulting in unexpected behavior. if there is no file data, the file is invalid.
40+
41+
if(!buf.length)
42+
return;
3543

3644
return req.files[fieldname] = {
3745
name: filename,
@@ -50,6 +58,8 @@ module.exports = function(options) {
5058
});
5159
}
5260
};
61+
62+
5363
});
5464
});
5565

0 commit comments

Comments
 (0)