SmartUpload su = new SmartUpload(); //新建一个SmartUpload对象 su.getRequest().getParameterValues(String name); //取数组值 su.getRequest().getParameter(String name); //取单个参数单个值
String softname=su.getRequest().getParameter("softname");
<span style="font-size:14px;">public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
SmartUpload mySmartUpload = new SmartUpload();
try{
// Initialization
mySmartUpload.initialize(config,request,response);
mySmartUpload.setMaxFileSize(10*1024*1024);//限制上传文件的大小
//mySmartUpload.setAllowedFilesList("txt,html,jpg,js");//设置允许上传的文件类型
mySmartUpload.setDeniedFilesList("exe,doc");//设置禁止上传的文件列表
mySmartUpload.upload();
String hString = mySmartUpload.getRequest().getParameter("name1");
//System.out.println(hString);
//System.out.println(mySmartUpload.getFiles().getCount());
for(int i = 0 ;i <mySmartUpload.getFiles().getCount();i++){//多个文件的上传
File file = mySmartUpload.getFiles().getFile(i);
if(file.getSize()!=0){
//拼凑上传文件的新名称
String fileNameString = System.currentTimeMillis()+"."+file.getFileExt();
//通过servlet的实际路径拼凑上传文件的保存路径,实际使用需要修改此路径
String path = "/upload123123"+java.io.File.separator+fileNameString;
file.saveAs(path);
}
Thread.sleep(100);
/*下载文件的语句
mySmartUpload.downloadFile("/路径"+"文件名称");*/
}
}catch(Exception e){
e.printStackTrace();
}
}</span>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有