<%@ page contentType="text/html;Charset=gbk"%>
<%@page import="com.jspsmart.upload.*"%>
<%
request.setCharacterEncoding("gbk");
myUpload.initialize(pageContext);
//myUpload.setMaxFileSize(1000000);//限定上载500K的单个文件
try{
myUpload.upload();
}
catch(NullPointerException e){}
//限定上载文件的大小 3MB
if(myUpload.getFiles().getSize()>3000000){
out.print("文件超出3M");
}
else{
String fname="",temp="";
try{
com.jspsmart.upload.File myFile = myUpload.getFiles().getFile(0);
if (!myFile.isMissing()) {
fname=fname+myFile.getFileName();
temp=fname+"."+myFile.getFileExt();
myFile.saveAs("./upload/" + temp,myUpload.SAVE_VIRTUAL);
}
}catch(Exception e){e.printStackTrace();}
}
String username=myUpload.getRequest().getParameter("username");
out.print("username="+username);
%>
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/21154288/viewspace-573414/ ,如需转载,请注明出处,否则将追究法律责任。