文件名称:图片上传filemover.jar,uploadbean.jar,cos.jar
文件大小:72KB
文件格式:RAR
更新时间:2011-11-16 04:19:26
另类实现图片上传功能组件
用于图片上传功能,前台后台都能实现 后台实现代码: FileMover fileMover = new FileMover(); UploadBean upBean = new UploadBean(); MultipartFormDataRequest mrequest = null; Hashtable files = null; mrequest = new MultipartFormDataRequest(request,null,100*1024*1024,MultipartFormDataRequest.COSPARSER,"GBK"); files = mrequest.getFiles(); String sWebRootPath = request.getRealPath("/"); String sPath=sWebRootPath+"file"; String sLocalFileName = ""; int iFileCount = 0; if ( (files != null) || (!files.isEmpty()) ) { UploadFile file = (UploadFile) files.get("file"); sLocalFileName=file.getFileName(); File dir =new File(sPath); if (!dir.exists()){ dir.mkdirs(); } upBean.setFolderstore(sPath); upBean.addUploadListener(fileMover); fileMover.setNewfilename(sLocalFileName); upBean.store(mrequest, "file"); }
【文件预览】:
新建文件夹
----filemover.jar(2KB)
----cos.jar(47KB)
----uploadbean.jar(30KB)