就是 比如两个文本框 第一个是 文件路径/文件名.扩展名
第二个文本框 自动显示  文件名  就可以了 谢谢
就是 第一个文本框显示 d:/cyc.rar
第二个文本框用js    直接显示 cyc  并且可以编辑

解决方案 »

  1.   

    <script>
    function c(fn)
    {
      t = fn.split("\\");
      document.getElementById('name').value = t[t.length-1];
    }
    </script>
    <input type="file" id="image" onpropertychange="c(this.value)">
    <input type="text" id="name">
      

  2.   

    把“onpropertychange”改为“onchange”
      

  3.   

    "d:/cyc.rar".split("/")[1].split(".")[0]
      

  4.   

    就是   比如两个文本框   第一个是   文件路径/文件名.扩展名 
    第二个文本框   自动显示     文件名     就可以了   谢谢 
    就是   第一个文本框显示   d:/cyc.rar 
    第二个文本框用js         直接显示   cyc     并且可以编辑 上面的 都不对啊  其实第一个文本框是 上传组件 一个文本框 一个按钮的那种 谢谢 应该如何改一下
      

  5.   

    建议你用 ajax 从服务器获得文件的信息 再作分析
      

  6.   

    <script> 
    function   c(fn) 

        t   =   fn.split( "\\ "); 
        document.getElementById( 'name ').value   =   t[t.length-1]; 

    </script> 
    <input   type= "file "   id= "image "   onpropertychange= "c(this.value) "> 
    <input   type= "text "   id= "name ">  
     
     
    这段代码 有时候可以获得 但是 不是很好用阿 帮我看看是不是有什么问题 ,谢谢 大家了
      

  7.   

    8楼的办法应该也是可以的 不过要看你实现什么功能了:<script>
    function c(fn)
    {
        t = fn.split("\\");
        document.getElementById('name').value = t[t.length-1];
    }
    </script>
    <input type= "file" id= "image" onchange="c(this.value) ">
    <input type= "text" id= "name">
      

  8.   

    <script>
    function c(fn)
    {
        t = fn.split("\\");
        document.getElementById('name').value = t[t.length-1];
    }
    </script>
    <input type= "file" id= "image" onchange="c(this.value) ">
    <input type= "text" id= "name">
      

  9.   

    靠 csdn 的编辑器搞什么 怎么老加没用的 空格 
      

  10.   

    中间那一行改成 document.getElementById('name').value = t[t.length-1].replace(/\.(.*)/g, ''); 就可以了
      

  11.   

    <script>
    function cn(fn)
    {
    t = fn.split("\\");
    t = t[t.length-1].split(".");
    n = new Array();
    for(c=0; c<t.length-1; c++) n[n.length]=t[c];
    document.getElementById('name').value = n.join(".");
    }
    </script>
    <input type="file" id="image" onchange="cn(this.value)">
    <input id="name">
      

  12.   

    <script>function cn(fn)
    {
    t = fn.split("\\");
    t = t[t.length-1].split(".");
    n = new Array();
    for(c=0; c<t.length-1; c++) n[n.length]=t[c];
    document.getElementById('name').value = n.join(".");
    }</script><input type="file" id="image" onchange="cn(this.value)">
    <input id="name">
      

  13.   

    <script> 
    function   cyc(filename) 

    t1= filename.lastIndexOf("."); 
    t2= filename.lastIndexOf("\\"); 
        t3 = filename.substring(t2+1, t1); 
        document.getElementById('name').value=t3; 
    }
    </script> <body>
    <input   type= "file"  id= "image"  onchange= "cyc(this.value) "> 
    <input   type= "text"  id= "name"> 
    </body>搞定了 呵呵 
      

  14.   

    document.getElementById('name').value = t[t.length-1].replace(/\.(.*)/g, '');
      

  15.   

    如果文件名有两个点怎么办?
    t[t.length-1].replace(/\.(.*)/g, '');
    这种写法只能获取第一个点前面的内容。