Friday, 15 January 2010

html - Chrome file upload bug: file name goes wrong when choose for the second time -


I am working on a simple web page with a file upload control:

  & Lt; Input type = "file" name = "file" & gt;  

And when I test it, I find this strange bug: When I select a file from disk for the second time, the name of the file will be incorrect. For example, when I select the E: \ tmp \ 123456789012345.jpg , the value of the input is C: \ fakepath \ 123456789012345.jpg , which is correct. But if I click on the Browse button again and choose the file e: \ tmp \ a.jpg then the value of the input will be C: \ fakepath \ 45.jpg < / Code> due to which the file does not get fault.

After a repeated experiment with different files, I know that the bug occurs when I select a file with a long filename, and then choose a smaller file name

In addition, the broken file name is a "suffix" of long file name (first selected), and broken_file_name.length + correct_file_name.length == long_file_name - 4 .

An example case and related console output:

  // first, e: \ tmp \ 123456789012345.jpg & gt; $ ('Input [name = "file"]'). Val () & lt; "C: \ fakepath \ 123456789012345.jpg" & gt; $ ('Input [name = "file"]'). Val (). Length & lt; 31 // Then select E: \ Tmp \ a.jpg & gt; $ ('Input [name =' file "] '). Val () & lt; "C: \ fakepath \ 45.jpg" // should be "C: \ fakepath \ A" Jpg "> $ ('input [name =' file"] '). Val () Length. <18 // 17 should be E: \ tm P \ 123456789012345.jpg again, and then E: \ tmp \ ab.jpg & gt; $ (select 'input [name =' file "] '). Val () & lt ; "C: \ fakepath \ .jpg" / / "should be": "c: \ fakepath \ ab.jpg"> $ ('input [name = "file"]'). Val () Length & Lt; 17 // should choose 18 / E: Choose \ tmp \ 123456789012345.jpg again, and then E: \ tmp \ abc.jpg & gt; $ ('input [name =' file "] '). Val () & lt; "C: \ fakepath \ .jpg" // should be "C: \ fakepath \ abc.jpg"> $ ('input [name =' file "] '). Val (). Length should be of <16 / / 1  

I Tried to find in the list of issues of theromium, and nothing was found.

The bug is on chrome 39, and disappears on chrome 41. And on disk instead of "c: \"

Any ideas?


No comments:

Post a Comment