var finame = document.all.filename1.value;
finame = flname.subString(finame.lastIndexof("\")+1);
document.getElementById("imgname").value = finame;<td id="imgname">显示图片名字 </td> 

解决方案 »

  1.   

    这样?
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    </head>
    <body>
    <form name="fileUploadForm" action="localFileUpload.nhn" 
            method="post" enctype="multipart/form-data">
        filename1 : <input type="file" name="filename1"> <br> 
        filename2 : <input type="file" name="filename2"> <br> 
        filename3 : <input type="file" name="filename3"> <br> 
        filename4 : <input type="file" name="filename4"> <br>     <input type="submit"> 
      <table> 
        <tr> 
          <td id="img_name">显示图片名字 </td> 
        </tr> 
      </table> 
    </form>
    <script>
    var fs = document.forms['fileUploadForm'].elements;
    var img_name = document.getElementById('img_name');
    for(var i=0; i<fs.length; i++){
    if(fs[i].type=='file'){
    fs[i].onchange = function(){
    img_name.innerHTML = this.value.replace(/^.+(?:\/|\\)([^\/\\]+)$/,'$1');
    }
    }
    }
    </script>
    </body>
    </html>
      

  2.   


    <form name="fileUploadForm" action="localFileUpload.nhn" 
            method="post" enctype="multipart/form-data">     filename1 : <input type="file" name="filename1" onChange="showName(this);"> <br> 
        filename2 : <input type="file" name="filename2" onChange="showName(this);"> <br> 
        filename3 : <input type="file" name="filename3" onChange="showName(this);"> <br> 
        filename4 : <input type="file" name="filename4" onChange="showName(this);"> <br>     <input type="submit"> 
      <table> 
        <tr> 
          <td id="imageName">显示图片名字 </td> 
        </tr> 
      </table> 
    </form>
    <script>
    function showName(file){
    var fileName=file.value.replace(/^.*\\([^\\]+)$/g,"$1");
    document.getElementById("imageName").innerHTML=fileName;
    }
    </script>
      

  3.   

    谢谢  楼上的高手们  
      
      还有一个问题就是
           
               filename1 上传了 1.jsp 下面显示了 filename2 上传了 2.jsp 下面显示了  我想以下这么做的话 怎么写呢
    <form name="fileUploadForm" action="localFileUpload.nhn" 
            method="post" enctype="multipart/form-data">     filename1 : <input type="file" name="filename1" onChange="showName(this);"> <br> 
        filename2 : <input type="file" name="filename2" onChange="showName(this);"> <br> 
        filename3 : <input type="file" name="filename3" onChange="showName(this);"> <br> 
        filename4 : <input type="file" name="filename4" onChange="showName(this);"> <br>     <input type="submit"> 
      <table> 
        <tr> 
          <td id="imageName">显示图片名字  1.jsp  </td> 
          <td id="imageName1">显示图片名字  2.jsp  </td>
        </tr> 
      </table> 
    </form>
      

  4.   

    <form name="fileUploadForm" action="localFileUpload.nhn" 
            method="post" enctype="multipart/form-data">     filename1 : <input type="file" name="filename1" onChange="showName(this);"> <br> 
        filename2 : <input type="file" name="filename2" onChange="showName(this);"> <br> 
        filename3 : <input type="file" name="filename3" onChange="showName(this);"> <br> 
        filename4 : <input type="file" name="filename4" onChange="showName(this);"> <br>     <input type="submit"> 
      <table> 
        <tr> 
          <td id="imageName">显示图片名字 </td> 
        </tr> 
      </table> 
    </form>
    可是我选择filename1浏览上传1.jsp  下面显示1.jsp
    filename2浏览上传2.jsp  下面显示2.jsp 这样做的话怎么写呢
      

  5.   

    <form name="fileUploadForm" action="localFileUpload.nhn" method="post" enctype="multipart/form-data">
    filename1 : <input type="file" name="filename1"> <br> 
    filename2 : <input type="file" name="filename2"> <br> 
    filename3 : <input type="file" name="filename3"> <br> 
    filename4 : <input type="file" name="filename4"> <br> <input type="submit"> 
    <table> 
    <tr> 
      <td id="img_list"> </td> 
    </tr> 
    </table> 
    </form>
    <script>
    var fs = document.forms['fileUploadForm'].elements;
    var img_list = document.getElementById('img_list');
    for(var i=0; i<fs.length; i++){
    if(fs[i].type=='file'){
    fs[i].onchange = function(){
    img_list.innerHTML = get_imglist().join('<br />');
    }
    }
    }function get_imglist(){
    var list = [];
    for(var i=0; i<fs.length; i++){
    if(fs[i].type == 'file' && fs[i].value)list.push('filename'+(i+1)+':'+fs[i].value.replace(/^.+(?:\/|\\)([^\/\\]+)$/,'$1'));
    }
    return list;
    }
    </script>
      

  6.   

    <form name="fileUploadForm" action="localFileUpload.nhn" 
            method="post" enctype="multipart/form-data">     filename1 : <input type="file" name="filename1" onChange="showName(this);"> <br> 
        filename2 : <input type="file" name="filename2" onChange="showName(this);"> <br> 
        filename3 : <input type="file" name="filename3" onChange="showName(this);"> <br> 
        filename4 : <input type="file" name="filename4" onChange="showName(this);"> <br>     <input type="submit"> 
      <table border="1"> 
        <tr> 
          <td id="imageName1">显示图片名字 </td> 
      <td id="imageName2">显示图片名字 </td> 
      <td id="imageName3">显示图片名字 </td> 
      <td id="imageName4">显示图片名字 </td> 
        </tr> 
      </table> 
    </form>
    <script>
    function showName(file){
    var fileName=file.value.replace(/^.*\\([^\\]+)$/g,"$1");
    document.getElementById("imageName"+file.getAttribute("name").replace(/filename/g,"")).innerHTML=fileName;
    }
    </script>
      

  7.   

    <form name="fileUploadForm" action="localFileUpload.nhn" method="post" enctype="multipart/form-data">
    filename1 : <input type="file" name="filename1"> <br> 
    filename2 : <input type="file" name="filename2"> <br> 
    filename3 : <input type="file" name="filename3"> <br> 
    filename4 : <input type="file" name="filename4"> <br> <input type="submit"> 
    <table> 
    <tr> 
      <td id="img_list"> </td> 
    </tr> 
    </table> 
    </form>
    <script>
    var fs = document.forms['fileUploadForm'].elements;
    var img_list = document.getElementById('img_list');
    for(var i=0; i<fs.length; i++){
        if(fs[i].type=='file'){
            fs[i].onchange = function(){
                img_list.innerHTML = get_imglist().join('<br />');
            }
        }
    }function get_imglist(){
        var list = [];
        for(var i=0; i<fs.length; i++){
            if(fs[i].type == 'file' && fs[i].value)
       list.push('<input type="checkbox">'+(i+1)+':'+fs[i].value.replace(/^.+(?:\/|\\)([^\/\\]+)$/,'$1'));
        }
        return list;
    }
    </script>
    在这个基础上 加全选和删除按钮的话....
      

  8.   

    搞定,真麻烦,下班了,给分儿吧楼主 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <form name="fileUploadForm" action="localFileUpload.nhn" method="post" enctype="multipart/form-data"> 
    filename1 : <input type="file" name="filename1"> <br> 
    filename2 : <input type="file" name="filename2"> <br> 
    filename3 : <input type="file" name="filename3"> <br> 
    filename4 : <input type="file" name="filename4"> <br> <input type="submit" value="提交查询"> 
    <input type="button" onclick="selAll()" value="全选" /> <input type="button" onclick="del()" value="删除" />
    <table> 
    <tr> 
      <td id="img_list"> </td> 
    </tr> 
    </table> 
    </form> 
    <script> 
    var fs = document.forms['fileUploadForm'].elements; 
    var img_list = document.getElementById('img_list'); 
    for(var i=0; i <fs.length; i++){ 
        if(fs[i].type=='file'){ 
            fs[i].onchange = function(){ 
                img_list.innerHTML = get_imglist().join(' <br />'); 
            } 
        } 
    } function get_imglist(){ 
        var list = []; 
        for(var i=0; i <fs.length; i++){ 
            if(fs[i].type == 'file' && fs[i].value) 
      list.push(' <input type="checkbox" value="'+i+'">'+(i+1)+': '+fs[i].value.replace(/^.+(?:\/ ¦\\)([^\/\\]+)$/,'$1')); 
        } 
        return list; 
    }function selAll(){
    var cs = img_list.getElementsByTagName('input');
    for(var i=0; i<cs.length; i++)cs[i].checked = true;
    }function del(){
    var fils = [];
    for(var i=0; i<fs.length; i++)if(fs[i].type == 'file') fils.push(fs[i]);
    var cs = img_list.getElementsByTagName('input');
    for(var i=0; i<cs.length; i++)
    if(cs[i].checked){
    var n = parseInt(cs[i].value);
    var nfile = fils[n].cloneNode(true);
    fils[n].parentNode.replaceChild(nfile, fils[n]);
    }
    img_list.innerHTML = get_imglist().join(' <br />');
    }
    </script> 
      

  9.   

    cgisir你的 QQ是多少我加你吧
      

  10.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>无标题页</title>
        <script>
    function add()
    {var obj=document.getElementById("s1").insertRow().insertCell();
    var obj1=document.createElement("input");
    obj1.type="checkbox";
    obj.appendChild(obj1);
    var str=document.getElementById("s2").value;
    obj.appendChild(document.createTextNode(str));
    }
    function del()
    {
    var l1=document.getElementsByTagName("input");
    var obj=document.getElementsByTagName("tr");
    for(var i=1;i<obj.length;i++)
    {
    if(l1[i+2].checked==true&&l1[i+2].type=="checkbox")
    {
    document.getElementById("s1").deleteRow(i);
    }
    }
    }
    </script>
    </head>
    <body>
    <table id="s1" border="1">
    <tr>
    <td>
    <input type="file" id="s2"/><input type="button" value="增加" onclick="add()"/><input type="button" value="删除" onclick="del()"/>
    </td>
    </tr>
    </table>
    </body>
    </html>
      

  11.   

    有点小错误 
    还是帮你加shang
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>无标题页</title>
        <script>
    function add()
    {var obj=document.getElementById("s1").insertRow().insertCell();
    var obj1=document.createElement("input");
    obj1.type="checkbox";
    obj.appendChild(obj1);
    var str=document.getElementById("s2").value;
    obj.appendChild(document.createTextNode(str));
    }
    function del()
    {
    var l1=document.getElementsByTagName("input");
    var obj=document.getElementsByTagName("tr");
    for(var i=obj.length-1;i>0;i--)
    {
    if(l1[i+2].checked==true&&l1[i+2].type=="checkbox")
    {
    document.getElementById("s1").deleteRow(i);
    }
    }
    }
    </script>
    </head>
    <body>
    <table id="s1" border="1">
    <tr>
    <td>
    <input type="file" id="s2" onchange="add()"/><input type="button" value="增加"/><input type="button" value="删除" onclick="del()"/>
    </td>
    </tr>
    </table>
    </body>
    </html>