怎样得到:ENCTYPE="multipart/form-data"中提交的表单的值?
fzlhx 2003-10-27 01:28:55 1.jsp
<FORM METHOD="POST" ACTION="upfile.jsp" ENCTYPE="multipart/form-data">
文件ID:<input name="id" size="10">
<br/>
<input type="text" name="xgsj">时间
选择要上传文件:<input type="file" name="image">
<br/>
<input type="submit" value="上传" name="submit" size="25">
<input type="reset" value="清除" name="clear" size="25">
<br/> </form>
2.jsp
<%@ page language="java" import="com.jspsmart.upload.*"%>
<%@ page import="java.sql.*"%>
<jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" />
<jsp:useBean id="conn" scope="page" class="htjs.database.DB_link"/>
<jsp:useBean id="jsp" scope="page" class="htjs.basic.OutString"></jsp:useBean>
<HTML>
<BODY BGCOLOR="white">
<center><H1>上传文件</H1></center>
<HR>
<%
// Variables
int count=0;
String sql="";
//String id=request.getParameter("id1");
String xgsj=request.getParameter("xgsj");
String yhbm=(String)session.getAttribute("yhbm");
String username=(String) session.getValue("username");
// Initialization
mySmartUpload.initialize(pageContext);
// Upload
mySmartUpload.upload();
// Select each file
for (int i=0;i<mySmartUpload.getFiles().getCount();i++){
// Retreive the current file
com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(i);
// Save it only if this file exists
if (!myFile.isMissing()) {
// Save the files with its original names in a virtual path of the web server
myFile.saveAs("/upfile/" + myFile.getFileName());
// myFile.saveAs("/upload/" + myFile.getFileName(), mySmartUpload.SAVE_VIRTUAL);
// sample with a physical path
//myFile.saveAs("c:\\temp\\" + myFile.getFileName(),mySmartUpload.SAVE_PHYSICAL);
// Display the properties of the current file
out.println("FieldName = " + myFile.getFieldName() + "<BR>");
out.println("Size = " + myFile.getSize() + "<BR>");
out.println("FileName = " + myFile.getFileName() + "<BR>");
out.println("FileExt = " + myFile.getFileExt() + "<BR>");
out.println("FilePathName = " + myFile.getFilePathName() + "<BR>");
out.println("ContentType = " + myFile.getContentType() + "<BR>");
out.println("ContentDisp = " + myFile.getContentDisp() + "<BR>");
out.println("TypeMIME = " + myFile.getTypeMIME() + "<BR>");
out.println("SubTypeMIME = " + myFile.getSubTypeMIME() + "<BR>");
count ++;
sql="begin insert into tfiles(id,FieldName,Size1,FileName,FileExt,FilePathName,ContentType,ContentDisp,TypeMIME,SubTypeMIME) values('"+yhbm+"','" + myFile.getFieldName() + "','" + myFile.getSize() + "','" + myFile.getFileName() + "','" + myFile.getFileExt() + "','" + myFile.getFilePathName() + "','" + myFile.getContentType() + "','" + myFile.getContentDisp() + "','" + myFile.getTypeMIME() + "','" + myFile.getSubTypeMIME()+ "');end;";
conn.executeQuery(sql);
out.print(sql);
}
}
// Display the number of files which could be uploaded
out.println("<BR>" + mySmartUpload.getFiles().getCount() + " files could be uploaded.<BR>");
// Display the number of files uploaded
out.println(count + "个文件上传成功.");
if (conn!=null) conn.close();
%>
</BODY>
</HTML>
问题:怎样得到1.jsp中的xgsj(时间的值)?
我用的上传组件:jspsmart.