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


i working on simple web page file upload control:

<input type="file" name="file"> 

and when test it, find strange bug: when choose file disk second time, file name go wrong.

for example, when choose e:\tmp\123456789012345.jpg, value of input c:\fakepath\123456789012345.jpg, correct. if click browse button again , choose file e:\tmp\a.jpg, value of input become c:\fakepath\45.jpg, causing file not found error afterwards.

after repeated test different files, find out bug occurs when choose file longer file name, , choose shorter file name.

also, broken file name "suffix" of longer file name (chosen @ first time), , broken_file_name.length + correct_file_name.length == long_file_name - 4.

an example case , corresponding console output:

// first, choose e:\tmp\123456789012345.jpg >$('input[name="file"]').val() <"c:\fakepath\123456789012345.jpg" >$('input[name="file"]').val().length <31  // choose e:\tmp\a.jpg >$('input[name="file"]').val() <"c:\fakepath\45.jpg"  // should "c:\fakepath\a.jpg" >$('input[name="file"]').val().length <18  // should 17  // choose e:\tmp\123456789012345.jpg again, , choose e:\tmp\ab.jpg >$('input[name="file"]').val() <"c:\fakepath\5.jpg"  // should "c:\fakepath\ab.jpg" >$('input[name="file"]').val().length <17  // should 18  // choose e:\tmp\123456789012345.jpg again, , choose e:\tmp\abc.jpg >$('input[name="file"]').val() <"c:\fakepath\.jpg"  // should "c:\fakepath\abc.jpg" >$('input[name="file"]').val().length <16  // should 19 

i tried searching @ chromium issues list, , got nothing.

the bug occurs on chrome 39, , disappears on chrome 41. , ie works fine due using real path on disk instead of "c:\fakepath".

any ideas?


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -