response.setContentType("text/html;charset=gb2312");
PrintWriter out = response.getWriter();
SmartUpload mySmartUpload = new SmartUpload();
String currentDirectoryPath=null;
String savePath="E:/public_html/java_root/NETDISK/WebRoot/NET_SPACE/1/我的音乐/";
//mySmartUpload.setDenyPhysicalPath(true);
mySmartUpload.setForcePhysicalPath(true);
mySmartUpload.initialize(this.getServletConfig(), request,response);
// 设定上传限制
// 1.限制每个上传文件的最大长度。10M
mySmartUpload.setMaxFileSize(10000000);
// 2.限制总上传数据的长度。
// mySmartUpload.setTotalMaxFileSize(20000);
// 3.设定允许上传的文件(通过扩展名限制),仅允许doc,txt文件。
// mySmartUpload.setAllowedFilesList("doc,txt");
// 4.设定禁止上传的文件(通过扩展名限制),禁止上传带有exe,bat, jsp,htm,html扩展名的文件和没有扩展名的文件。
// mySmartUpload.setDeniedFilesList("exe,bat,jsp,htm,html,,");
// Deny physical path
try {
mySmartUpload.upload();
} catch (SmartUploadException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
//读取其它数据
com.jspsmart.upload.Request req = mySmartUpload.getRequest();
String title = req.getParameter("dest");
//保存文件
for (int i = 0; i < mySmartUpload.getFiles().getCount(); i++) {
com.jspsmart.upload.File file = mySmartUpload.getFiles().getFile(i);
if (file.isMissing()) continue;
try {
file.saveAs(savePath+file.getFileName());
} catch (SmartUploadException e) {
// TODO Auto-generated catch block
e.printStackTrace();
logger.info("e:"+e);
}
}
out.println("dest:"+title);
out.close();
PrintWriter out = response.getWriter();
SmartUpload mySmartUpload = new SmartUpload();
String currentDirectoryPath=null;
String savePath="E:/public_html/java_root/NETDISK/WebRoot/NET_SPACE/1/我的音乐/";
//mySmartUpload.setDenyPhysicalPath(true);
mySmartUpload.setForcePhysicalPath(true);
mySmartUpload.initialize(this.getServletConfig(), request,response);
// 设定上传限制
// 1.限制每个上传文件的最大长度。10M
mySmartUpload.setMaxFileSize(10000000);
// 2.限制总上传数据的长度。
// mySmartUpload.setTotalMaxFileSize(20000);
// 3.设定允许上传的文件(通过扩展名限制),仅允许doc,txt文件。
// mySmartUpload.setAllowedFilesList("doc,txt");
// 4.设定禁止上传的文件(通过扩展名限制),禁止上传带有exe,bat, jsp,htm,html扩展名的文件和没有扩展名的文件。
// mySmartUpload.setDeniedFilesList("exe,bat,jsp,htm,html,,");
// Deny physical path
try {
mySmartUpload.upload();
} catch (SmartUploadException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
//读取其它数据
com.jspsmart.upload.Request req = mySmartUpload.getRequest();
String title = req.getParameter("dest");
//保存文件
for (int i = 0; i < mySmartUpload.getFiles().getCount(); i++) {
com.jspsmart.upload.File file = mySmartUpload.getFiles().getFile(i);
if (file.isMissing()) continue;
try {
file.saveAs(savePath+file.getFileName());
} catch (SmartUploadException e) {
// TODO Auto-generated catch block
e.printStackTrace();
logger.info("e:"+e);
}
}
out.println("dest:"+title);
out.close();