如何给File类型的输入栏设置缺省值?

mobbs 2006-04-24 09:53:43
如何给File类型的输入栏设置缺省值?
如下代码
<tr>
<td width="104" ><div align="right">附件1:</div></td>
<td><input type="FILE" name="FILE1" size="50" value="C:\starcraft\MAPS\(2)Challenger.scm"></td>
</tr>
如果IE中我点击‘浏览...’再选择这个.scm文件,再看源代码,就是如上。
但是如果我直接在源文件中如上写了,则IE中FILE1一栏却是空的,就是说缺省值设不了。
有什么办法可以设这个缺省值吗?
...全文
206 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
mobbs 2006-04-24
  • 打赏
  • 举报
回复
1楼高见。谢谢。结贴!
zhishao 2006-04-24
  • 打赏
  • 举报
回复
既然大家已把此当作一个安全问题,反言之,对于存在file.value安全漏洞的浏览器而言。你的需求还是可能实现的——从以下的声明找找这样的老古董浏览器还不少呢。只不过,这可能并不单单取决于你的意愿。


Internet Explorer and Netscape do not use the VALUE attribute as the default contents of the input area. Any default value set via HTML is not usable via scripting and the DOM as well (hence it is not listed as 'supported' in any of the browsers.) If a user enters text in the field however, that value is then reachable via the DOM as it normally would be for a normal INPUT field (via the .value property.) The reason for this behavior would presumably be to ensure the security/safety of users against malicious authors. Opera displays the default VALUE attribute value and submits it as well (although it prompts for confirmation on submit if you have not altered that value.)

Netscape 2+ only supports the onChange event handler attribute in cases where the user enters or modifies text via the text box; if the "Browse..." button is the only thing used, the event is not fired. Internet Explorer 4.0+ fires the event in both cases.

Netscape 4+ allows some Character-level formatting to be applied to the contents of this form field. These physical formatting elements (along with virtual formatting elements that are rendered identically, such as EM and I) apply to this form field: I, U, S, STRIKE, SUB, SUP, BIG, SMALL, FONT SIZE and FONT FACE.

Using a READONLY attribute in IE4 and IE5 on this element still allows a user to invoke the file...open dialog (from the "Browse..." button), although the text field is not directly editable. In IE5.5 plus, both the text field AND the file...open dialog are not usable.

Opera 5/6: Using the DISABLED attribute still sends the name/value pair for the element to the form processing script. It should not do this.
zuguanqun 2006-04-24
  • 打赏
  • 举报
回复
没用过,学习一下
wsk_228 2006-04-24
  • 打赏
  • 举报
回复
应该是不可以的,也没见过这样
jihanzhong 2006-04-24
  • 打赏
  • 举报
回复
不能! 假如能的话,给你机器传一个这样的html文件,用简单的脚本就可以把你机器上的东东弄走了,你说对不对?

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧