日期:2014-05-18  浏览次数:20832 次

用smartupload上传文件时死机
SmartUpload   su   =   new   SmartUpload();
System.out.println( "new   SmartUpload   is   ok ");
su.initialize(pageContext);
System.out.println( "su.initialize   is   ok ");
su.upload();
System.out.println( "su.upload   is   ok ");
到su.upload();这里就不往下执行了,cpu100%
为什么

------解决方案--------------------
su.save()这个方法没调用!
------解决方案--------------------
只是读取了文件流,但没有输出保存到硬盘上!
------解决方案--------------------
是不是没设置这个参数?ENCTYPE= "multipart/form-data "
------解决方案--------------------
jspsmartupload的例子:
sample1.htm
<HTML>
<BODY BGCOLOR= "white ">

<H1> jspSmartUpload : Sample 1 </H1>
<HR>

<FORM METHOD= "POST " ACTION= "/jspsmartupload/jsp/sample1.jsp " ENCTYPE= "multipart/form-data ">
<INPUT TYPE= "FILE " NAME= "FILE1 " SIZE= "50 "> <BR>
<INPUT TYPE= "FILE " NAME= "FILE2 " SIZE= "50 "> <BR>
<INPUT TYPE= "FILE " NAME= "FILE3 " SIZE= "50 "> <BR>
<INPUT TYPE= "FILE " NAME= "FILE4 " SIZE= "50 "> <BR>
<INPUT TYPE= "SUBMIT " VALUE= "Upload ">
</FORM>

</BODY>
</HTML>


sample1.jsp

<%@ page language= "java " import= "com.jspsmart.upload.* "%>
<jsp:useBean id= "mySmartUpload " scope= "page " class= "com.jspsmart.upload.SmartUpload " />

<HTML>
<BODY BGCOLOR= "white ">
<H1> jspSmartUpload : Sample 1 </H1>
<HR>

<%
// Variables
int count=0;

// Initialization
mySmartUpload.initialize(pageContext);

mySmartUpload.setTotalMaxFileSize(100000);

// Upload
mySmartUpload.upload();

try {

// Save the files with their original names in the virtual path "/upload "
// if it doesn 't exist try to save in the physical path "/upload "
count = mySmartUpload.save( "/upload ");

// Save the files with their original names in the virtual path "/upload "
// count = mySmartUpload.save( "/upload ", mySmartUpload.SAVE_VIRTUAL);

// Display the number of files uploaded
out.println(count + " file(s) uploaded. ");

} catch (Exception e) {
out.println(e.toString());
}
out.println(pageContext);
%>

</BODY>
</HTML>