有一个问题,关于JS的,就是在后台上传一个d:\My Documents\My Pictures\015.jpg图片后,我想让这个文件名(015.jpg)出现在我另一个页面的文本框中,怎么实现呀,各位大侠帮忙看看

解决方案 »

  1.   

    用split方法分割"\"
    取最后一个就是 015.jpg了...
    你是用什么方法打开上传页面的?
    如果是子页面的话
    window.opener.document.blogFileForm.fileName.value=fileName;//blogFileForm 是你form的名字,fileName是文本框的名字
    //window.opener.document.getElementById("fileName").value=fileName;
      

  2.   

    看看我的上传文件例子吧,实现了你需要的。
    http://download.csdn.net/user/wula0010:多文件上传例子
      

  3.   

    这是我的第一个页面upload.jsp
    <%@ page contentType="text/html; charset=gb2312" language="java" import="java.util.*,com.jspsmart.upload.*" %>
    <html>
    <head>
    <title>上传文件</title></head>
    <body>
    <form id="form1" name="msform" method="post" action="do_upload.jsp" enctype="multipart/form-data" onSubmit="return Check_Found(this);">
    <%String files=(String)session.getAttribute("files");%>
    <table width="50%" border="1" align="center">
      <tr>
        <td align="center"><input type="text" name="name"></td>
      </tr>
      <tr>
        <td align="center">产品说明:
          <input type="file" name="file2" value="<%=files%>"/>
          <input type="submit" name="Submit" value="上传图片" /></td>
      </tr>
    </table>
    </form>
    </body>
    </html>
    这是第二个页面do_upload.jsp
    <%@ page contentType="text/html; charset=gb2312" language="java" import="java.util.*,com.jspsmart.upload.*" %>
    <html>
    <head>
    <title>文件上传处理页面</title>
    </head>
    <body>
    <%
    SmartUpload su=new SmartUpload();
    su.initialize(pageContext);
    su.upload();
    String name;
    int count=su.save("/upload",su.SAVE_VIRTUAL);
    out.println(count+"个文件上传成功!<br>");
    for(int i=0;i<su.getFiles().getCount();i++)
    {
    com.jspsmart.upload.File file=su.getFiles().getFile(i);
    if(file.isMissing()) continue;
    String files=file.getFileName();

    }
    %>
    </body>
    </html>
    要让他的上传的文件名出现在第一个页面中的文本框中