我单独只传文件是成功的,但是我再在传文件的页面加一些文件的标题、说明等文本框,再上传时上传后的文件名是Content-Disposition,而且大小是0.请问这是什么问题呢?

解决方案 »

  1.   

    成功的是
    <%@ page contentType="text/html;charset=GB2312" %>
    <HTML>
    <head>
    <title>上传文件示例</title>
    </head>
    <BODY>
    上传文件程序应用示例
    <FORM action="do_upload.jsp" method="post" ENCTYPE="multipart/form-data">
    请选择要上传的文件:<input type="file" name="upfile" size="50"> 
    <INPUT type="submit" value="提交">
    </FORM>
     </BODY>
    </HTML>
    失败的是
     <%@ include file="/admin/session.jsp" %>
    <html>
    <head>
    <title>图片上传</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <link href="/css/back.css" rel="Stylesheet" type="text/css" />
    </head>
    <body >
    <FORM name="Myform" action="do_upload.jsp" method="post" ENCTYPE="multipart/form-data">
      <table border=0 cellspacing=0 cellpadding=0  width="100%" >
      <tr>
    <td  colspan="5" background="/admin/images/bground.png" height="27"><strong>当前位置:添加图片</strong></td>
    </tr>  <tr height="40"><td height="34"></td><td height="34"><input type="hidden" name="newsid" value="<%=request.getParameter("newsid")%>"></td>
    <td rowspan="6" background="yellow" width="59%"><img  border="1" width="160" id="preview" src="/admin/images/preview.gif"></td></tr>
      <tr height="40"><td height="46">&nbsp;图片标题</td><td height="46">
      <input type="text" name="title" class="InputStyle_1"><font color="#FF0000">*</font></td></tr>
    <tr height="40"> 
    <td  width="13%">&nbsp;选择图片</TD>
    <td  width="27%"> 
    <input type="file" name="upfile" size="50" class="InputStyle_1" onchange=setTimeout('preview()',100)><font color="#FF0000">*</font>
    </td>
    </tr>
    <tr height="40">
    <td  width="13%">&nbsp;是否允许显示</td>
    <td><input name="ishead" type="radio" value="0" checked>
    是 
    <input type="radio" name="ishead" value="1" >
    否</td>
    </tr>
    <tr height="40">
    <td  width="13%">&nbsp;所属分类</td>
    <td>
    <%
    String sql="select type from news where id="+Integer.parseInt(request.getParameter("newsid"));
    rs.executeSql(sql);
    if (rs.next())
    {
    if (rs.getInt("type")==1)
    out.println("a");if (rs.getInt("type")==2)
    out.println("b");if (rs.getInt("type")==3)
    out.println("c");
    }
    %>
    <input type="hidden" name="kind" value="<%=rs.getInt("type")%>">
    </td>
    </tr>
    <tr height="40">
    <td></td><td><input type="submit" value="上传" name="B1" IsShowProcessBar="True" class="submit"></td>
    </tr>
    </table>
    </form>
    </body>
    </html>而用的都是一个处理文件。