<input type="file">如何设置值,默认的话不话,有没有变通的方法?

解决方案 »

  1.   

    file的value出于安全性考虑不能写.只能读.
      

  2.   

    file的value出于安全性考虑不能写.只能读   。
      

  3.   

    有两种方法:
    1、用模拟。<form name="myform">
    <input type="text" name="bb" value="D:\">
    <input type="button" value="浏览..." onclick="kk.click()">
    <input type="file" id="kk" style="display:none" onchange="bb.value=this.value">
    </form>
    2、用ActiveX控件,不过会提示不安全。<script language="javascript">
    window.onload=function(){
    ss.focus();
    var WshShell=new ActiveXObject("WScript.Shell")
    WshShell.sendKeys("D:\\test.txt")
    }
    </script>
    <input id="ss" type="file" name="ss">