好吧,大概的问题就如标题一样,那么我在说详细一点吧!
先看代码:
<form><input type="file" name="upFile" /><input type="submit" value="提交"></form>
大致的意思是:
当用户点击表单的浏览之后选择好了将要上传的本地文件之后,当他点击提交的时候我需要通过JS来获取File表单里面的值,这个值就是用户选择的本地文件的路径,比如:C:\\file\img\a.jpg请大神赐教!!!!!

解决方案 »

  1.   

    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
         <script type="text/javascript">
             var message = "";
             function showMessage() {
                 message += "Document File is " + $(":file").val() + "<br />";
                 message += "Radio Value is " + $("input[name='rView']:checked").val();//获取radio选中项
                 message += "<br/>CheckBox Value is ";
                 $("input[name='cView']:checked").each(function () {
                     message += $(this).val() + ",";
                 });//获取checkbox选中项
                 message = message.substring(0, message.length - 1);
                 message += "<br/>Select value is " + $("#sView").val();//获取select选中项
                 message += "<br/>Select value is " + $("input:text").val();
                 $("p").html("").html(message);
                 message = "";
             }
             function setSel(value) {
                 $("#sView").val(value);
             }
             function setRad(value) {
                 $("input[name='rView'][value=" + value + "]").attr("checked", "true");
             }
             function setChk(value) {
              var  a = value.split(",");
                 for (var i = 0; i < a.length; i++) {
                     $("input[name='cView'][value=" + a[i] + "]").attr("checked", "true");
                 }
             }
         </script></head>
    <body>
        <p>
        </p>
        <div>
            <table width="100%">
                <tr>
                    <td>
                        <input type="radio" name="rView" value="1" />显示
                        <input type="radio" name="rView" value="0" />不显示
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="text" name="" value="1" />显示
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="cView" value="1" />A
                        <input type="checkbox" name="cView" value="0" />B
                    </td>
                </tr>
                <tr>
                    <td>
                        <select id="sView">
                            <option value="1">A</option>
                            <option value="2">B</option>
                            <option value="3">C</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>
                        <input id="file1" type="file" />
                    </td>
                </tr>
            </table>
        </div>
        <div>
            <input type="button" value="获取值" onclick="showMessage()" />
            <input type="button" value="设置Select值为B" onclick="setSel(2)" />
            <input type="button" value="设置CheckBox值为显示" onclick="setChk('1,0')" />
            <input type="button" value="设置Radio值为不显示" onclick="setRad(0)" />
        </div>
    </body>
    </html>
      

  2.   

    这样不就可以 吗,ie9和chrome都可以<html> 
    <head>
    <meta http-equiv="Content-Language" content="zh-cn">
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
     
     
    <script language="javascript">  
    function showFilePath()
    {
    alert(document.getElementById("filepath").value);
    }
    </script>
      
    </head>
    <body > 
     <form><input type="file" name="upFile" id="filepath"/><input type="submit" value="提交" onclick="showFilePath()"></form>
    </body>
    </html> 
      

  3.   

    .value试试  但有些浏览器的安全机制可能获取不到
      

  4.   


    额,兄弟我表示不理解!你这段代码怎么解决我的问题的?整个HTML代码里连个<input type="file" />都没有出现.....
      

  5.   

    IE可以通过textrange获取真实的路径,通过value由于安全问题,IE7+以上要设置安全才能获取到全路径,firefox好像不行。。IE浏览器下获取file控件选择本地文件的路径