开发者

HTML file attribute issue

<input type="file" id="file-id" />
&l开发者_运维问答t;input type="text" name="file_path" id="file-path">

in jquery:

$("#file-path").val($("#file-id").val());
gives me : - 'C:\\fakepath\\test.py'

I am using ubuntu as my operating system. If I selected a file from /home/mylappy/Document/test.py It shows me the file path 'C:\\fakepath\\test.py'


For historical reasons, the value IDL attribute prefixes the filename with the string "C:\fakepath\". Some legacy user agents actually included the full path (which was a security vulnerability). As a result of this, obtaining the filename from the value IDL attribute in a backwards-compatible way is non-trivial. The following function extracts the filename in a suitably compatible manner: http://www.w3.org/TR/html5/number-state.html#file-upload-state

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜