文本与文件不能一起提交???????????????
input.htm
____________________
<form name= "form1 " method= "post " action= "postpr.jsp " enctype= "multipart/form-data ">
<table width= "100% " height= "450 " border= "1 " align= "center " cellpadding= "0 " cellspacing= "0 " bordercolor= "#D0EBFF " class= "x15 ">
<tr>
<td height= "100 " colspan= "2 "> <div align= "center "> <h3> 请输入服装信息 </h3> </div> </td>
</tr>
<tr>
<td width= "27% " height= "40 "> <div align= "center "> 名称(: </div> </td>
<td width= "73% " >
<form name= "form1 " method= "post " action= "publish_product.jsp " >
<input type= "text " name= "prName " </td>
</tr>
<tr>
<td height= "200 "> <div align= "center "> 介绍: </div> </td>
<td>
<textarea name= "prIntr " cols= "50 " rows= "18 "> </textarea>
</td>
</tr>
<tr>
<td> <div align= "center "> 产品图片: </div> </td>
<td> <input type= "file " name= "icon "> </td>
</tr>
<tr>
<td height= "40 " colspan= "2 ">
<div align= "center ">
<input type=submit value= "提交 "> </form>
</div> </td>
</tr>
</table>
postpr.jsp
_____________________________
SmartUpload su = new SmartUpload();
su.initialize(pageContext);
su.setAllowedFilesList( "jpg ");
su.setMaxFileSize(40000);
su.upload();
int count = su.save( "/c_product/icon ");
com.jspsmart.upload.File file = null;
for (int num=0;num <su.getFiles().getCount();num++)
{
file = su.getFiles().getFile(num);
if (file.isMissing()) continue;
String f_name = "/c_product/icon/ " + "wet1. " + file.getFileExt();
file.saveAs(f_name,su.SAVE_VIRTUAL);
}
System.out.println(request.getParameter( "prName "));
System.out.println(request.getParameter( "prIntr "));
System.out.println(request.getParameter( "cId "));
问题:若在form表单中写enctype= "multipart/form-data ",只能把图片存起来,System.out.println出来其余属性都时null;若不写,去掉file类型的字段,可正常println出,若加上file类型,提交后IE进度条一直停留在一半,无响应。难道文本与文件不能一起提交???????????????
各位帮忙
[解决办法]
可以的..
<%@ page contentType= "text/html; charset=GBK " %>
<%!private static final int PAGEID=-1;%>
<%!private static final int LEFTID=1;%>
<%@ include file= "../../common/function.jsp "%>
<%@ page import= "com.power.dapan.MainSHOP_TB.* "%>
<%@ page import= "com.power.dapan.MainSHOP_TB "%>
<%@ page import= "com.jspsmart.upload.* "%>
<jsp:include page= "../../common/top.jsp ">
<jsp:param name= "MenuId " value= "1 "/>
<jsp:param name= "GroupId " value= "1 "/>
</jsp:include>
<jsp:useBean id= "mySmartUpload " scope= "page " class= "com.jspsmart.upload.SmartUpload " />
<%
String filename[]={ " ", " "};
try
{
mySmartUpload.initialize(pageContext);
//文件上传
mySmartUpload.upload();
for(int i=0;i <2;i++)
{
com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(i);
if (!myFile.isMissing()) {
if (myFile.getFileName()!=null)
{
//myFile.deleteFile( "/attach/ " + resultTable.getfilename());
filename[i] = getNumberNowDate()+i+ ". "+myFile.getFileExt();
myFile.saveAs( "/attach/ " + filename[i]);
}
}
}
}
catch(Exception e)
{
}
%>
<%
String strBackInfo=getBackInfo();
String strLinkInfo=getLinkInfo( "保存产品数据 ");
%>
<%
String SHOPNAME=mySmartUpload.getRequest().getParameter( "SHOPNAME ");
String SHOPTYBE=mySmartUpload.getRequest().getParameter( "SHOPTYBE ");
String SHOPPIC=filename[0];
String SHOPDATA=MyDate.getNowDate();
String SHOPSM=mySmartUpload.getRequest().getParameter( "SHOPSM ");
MainSHOP_TB clsData=new MainSHOP_TB();
MyString strErr=new MyString();
boolean blnSuccess=clsData.newData(SHOPNAME,SHOPTYBE,SHOPPIC,SHOPDATA,SHOPSM,strErr);
%>
<SCRIPT LANGUAGE= "JavaScript "> document.title= "保存产品数据 " </SCRIPT>
<TABLE border= "0 " cellspacing= "0 " cellpadding= "0 " width= "100% ">
<TR> <TD height= "5 "> </TD> </TR>
<TR> <TD> <B> <FONT COLOR= "red "> <B> <%=strBackInfo+ "<<< "+ "保存产品数据 "%> </B> </FONT> </B> </TD> </TR>
<TR> <TD height= "3 "> </TD> </TR>
<TR> <TD height= "1 " bgcolor= "#330000 "> </TD> </TR>
<TR> <TD height= "5 "> </TD> </TR>
</TABLE>
<%
if(blnSuccess){%>
<B> <FONT COLOR= "red "> >>>保存数据成功! </FONT> </B>
<%
}
else{%>
<B> <FONT COLOR= "red "> >>>保存数据失败! <%=strErr.getValue()%> <A HREF= "javascript:history.back() "> 后退再试一次 </A> </FONT> </B>
<%}
%>
<jsp:include page= "../../common/foot.jsp "/>