<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
精彩评论