Javascript 为输入文件表单设置默认值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2665058/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 01:22:27  来源:igfitidea点击:

Set default value for a input file form

javascripthtml

提问by aladine

Possible Duplicate:
Dynamically set value of a file input

可能的重复:
动态设置文件输入的值

I have an input file HTML form and I want to set the initial value for the file path in an HTML form . I try to change tag "value" but it doesn't work anyway. <input type="file" name="testcase" value= "C:\test.txt">

我有一个输入文件 HTML 表单,我想在 HTML 表单中设置文件路径的初始值。我尝试更改标签“值”,但无论如何都不起作用。 <input type="file" name="testcase" value= "C:\test.txt">

Please give me some advice for this small problem. Thanks.

请给我一些关于这个小问题的建议。谢谢。

回答by anonymous

From HTMLHelp.com:

来自HTMLHelp.com

The file input type creates a field through which users can upload files from their local computer or network. The VALUE attribute specifies the name of the initial file, but it is typically ignored by browsers as a security precaution.

文件输入类型创建一个字段,用户可以通过该字段从本地计算机或网络上传文件。VALUE 属性指定初始文件的名称,但作为安全预防措施,浏览器通常会忽略它。

Therefore, setting an initial value is not supported.

因此,不支持设置初始值。