How to show file path in <input type=“file” /&g

2019-07-16 15:58发布

I tried <input type="file" value="path..." /> but not working.

How to fix?

标签: html file input
3条回答
劫难
2楼-- · 2019-07-16 16:39

As you don't know anything about the file structure on the users end, you cannot predefine the file to pick. And it would be pretty insecure when you could just make the <input /> hidden and send it with a form...

查看更多
Luminary・发光体
3楼-- · 2019-07-16 16:53

I am afraid that for security reasons this is not possible. The browser will dictate how the file input field will be handled and only the user can change the value by clicking on the Browse button.

From the W3C specification:

input type="file": Creates a file select control. User agents may use the value of the value attribute as the initial file name.

查看更多
看我几分像从前
4楼-- · 2019-07-16 16:55

The file input cannot be prepopulated by the webpage.

This is to avoid situations such as:

<input
  type="file"
  value="path-to-standard-location-for-quicken-data-files"
  style="display: none">
查看更多
登录 后发表回答