gpt4 book ai didi

jquery - HTML 文件属性问题

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:02:02 25 4
gpt4 key购买 nike

<input type="file" id="file-id" />
<input type="text" name="file_path" id="file-path">

jquery 中:

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

我正在使用 ubuntu 作为我的操作系统。如果我从 /home/mylappy/Document/test.py 选择一个文件,它会显示文件路径 '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

关于jquery - HTML 文件属性问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4849024/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com