// 上传图片
String ext = "";
String filename = "";
boolean uploadSucc = true;
int MAX_FILE_SIZE = 1000000;
int TOTAL_MAX_FILE_SIZE = 4000000;
String ALLOWED_FILE_TYPE = "jpg,gif,JPG,GIF";
SmartUpload su = new SmartUpload();
try {
su.initialize(this.getServletConfig(), request, response);
su.setMaxFileSize(MAX_FILE_SIZE);
su.setTotalMaxFileSize(TOTAL_MAX_FILE_SIZE);
su.setAllowedFilesList(ALLOWED_FILE_TYPE);
su.upload();
} catch (Exception e) {
log.writeTxtLog("LinkinfoServlet-doPost:", "upload"
+ e.getMessage() + "Fail");
}
String filePath = this.getServletConfig().getServletContext()
.getRealPath("/");
try {
com.jspsmart.upload.File file = su.getFiles().getFile(0);
ext = file.getFileExt();
Calendar calendar = Calendar.getInstance();
filename = String.valueOf(calendar.getTimeInMillis());
filename = filename + "." + ext;
file.saveAs(filePath + "\\link\\linkinfo\\upload\\" + filename,
SmartUpload.SAVE_PHYSICAL);
} catch (Exception e) {
log.writeTxtLog("LinkinfoServlet-doPost:", "upload Fail");
filename = "";
}
do not come in一直打印不出来 就直接跳到异常了 而打印出的异常是null
另外form里也加上了encType="multipart/form-data" 还是不行