get path from <input type=“file”/>

折月煮酒 提交于 2019-12-24 21:09:06

问题


I am using

    <input type="file" id="uploadFont" value="Upload Font"/>

to upload a font to my application. The open file dialog opens up and I choose the font.

How can I get the path of the choosen font.


回答1:


This is browser-dependant, but on modern secure browsers you can't - and this is a good thing. If you were able to read this path, an attacker would also be able to, which is a huge information leak - for example it mostly gives him your username, if you chose a file from e.g. "My Documents" or your home directory.

If you describe, what you need this path for, we might be able to help you conceive a workaround, but from the POV of your browser, this is just "some file", without the notion of its location in the underlying OS file tree.



来源:https://stackoverflow.com/questions/16802881/get-path-from-input-type-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!