smartupload为什么使用smartupload执行上传保存操作时用这句smart.save("upload")失败用smart.save("/upload")成功

smartupload  时间:2021-07-02  阅读:()

jspsmartupload.jar怎么用啊?

我以前项目使用过,但是后来被摒弃了,因为jspsmartupload.jar已经很久没有更新,而且它在上传大文件时会有问题 建议使mons-fileupload.jar(另外需mons-io.jar) 下面为部分源代码: /**Create a factory for disk-based file items*/ DiskFileItemFactory factory = new DiskFileItemFactory(); /**设置最大的内存大小*/ factory.setSizeThreshold(4096); /**创建一个新的文件上传操作*/ ServletFileUpload upload = new ServletFileUpload(factory); /**设置能上传的最大文件的大小*/ upload.setSizeMax(10*1024); /**Parse the request*/ List fileItems = upload.parseRequest(request); //开始读取上传信息 Iterator iter = fileItems.iterator(); // 依次处理每个上传的文件 while(iter.hasNext()) { FileItem item = (FileItem) iter.next(); // 忽略其他不是文件域的所有表单信息 if (!item.isFormField()) { String name = item.getName(); String endName = name.substring(name.lastIndexOf(".") + 1); try{ item.write(new File(request.getRealPath("\"+sUploadDir+FileName+"."+ endName))); }catch(Exception e){ e.printStackTrace(); }

SmartUpload中文乱码如何解决???文件名的在Servlet中提取。

中文乱码问题 你可以使用一个转中文的工具类,在我的空间里也有。

很方便。

打包为.jar文件的话,也需要个工具类。



算了 我直接贴这吧。

方便后来人也 jar包的话 你去下mons-io-1.2.jar 就行了。

以下是ZIP工具类~ ------------------------------------------ import java.io.*; import java.util.Enumeration; import java.util.zip.*; mons.io.FilenameUtils; /** * zip压缩工具。

暂不支持中文文件名。

* * @author zhangjin * */ public class ZipUtils { public static void main(String[] args) { long start = System.currentTimeMillis(); zip("D:/bak", "D:/test.zip"); // System.out.println(System.currentTimeMillis() - start); // start = System.currentTimeMillis(); // unzip("d:\test.zip", "d:\hoho"); System.out.println(getCRCCode("D:\sessionserver.jar")); System.out.println(System.currentTimeMillis() - start); } public static final int DATA_BUFFER = 8192; /** * 获得crc签名。

* @param filename * @return */ public static String getCRCCode(String filename){ String code = ""; try{ FileInputStream fileinputstream = new FileInputStream(filename); CRC32 crc32 = new CRC32(); CheckedInputStream checkedinputstream = new CheckedInputStream(fileinputstream, crc32); byte data[] = new byte[DATA_BUFFER]; while (checkedinputstream.read(data, 0, DATA_BUFFER)!=-1){} code = Long.toHexString(crc32.getValue()); } catch (Exception e) { e.printStackTrace(); } return code; } /** * 压缩文件,只处理一层目录,不处理多层目录。

* * @param srcdir * @param filename */ public static void zip(String srcdir, String filename) { try { //如果目录不存在,创建目录 String filepath = FilenameUtils.getFullPath(filename); File zippath = new File(filepath); if (!zippath.exists()) zippath.mkdirs(); ZipOutputStream out = new ZipOutputStream(new DataOutputStream( new FileOutputStream(filename))); subzip(srcdir, "", out); out.close(); } catch (Exception e) { e.printStackTrace(); } } /** * 递归处理多级目录。

* * @param srcdir * @param subdir * @param out * @throws Exception */ private static void subzip(String srcdir, String subdir, ZipOutputStream out) throws Exception { subdir = subdir.equals("") ? "" : (subdir.startsWith(File.separator) ? subdir : File.separator + subdir); File dirfile = new File(srcdir + subdir); // System.out.println(srcdir+subdir); String[] files = dirfile.list(); String subname = ""; for (int i = 0; i < files.length; i++) { subname = srcdir + subdir + File.separator + files[i]; if (new File(subname).isDirectory()) { subzip(srcdir, subdir + File.separator + files[i], out); } else { BufferedInputStream in = new BufferedInputStream( new FileInputStream(subname), DATA_BUFFER); out.putNextEntry(new ZipEntry((subdir.equals("") ? "" : (subdir .startsWith(File.separator) ? subdir.substring(1, subdir.length()) + File.separator : subdir + File.separator)) + files[i])); int count; byte data[] = new byte[DATA_BUFFER]; while ((count = in.read(data, 0, DATA_BUFFER)) != -1) { out.write(data, 0, count); } in.close(); } } } /** * 解压缩文件。

* * @param filename * @param destdir */ public static void unzip(String filename, String destdir) { try { BufferedOutputStream dest = null; BufferedInputStream is = null; ZipEntry entry; ZipFile zipfile = new ZipFile(filename); Enumeration e = zipfile.entries(); while (e.hasMoreElements()) { entry = (ZipEntry) e.nextElement(); // System.out.println("Extracting: " + entry); is = new BufferedInputStream(zipfile.getInputStream(entry)); int count; byte data[] = new byte[DATA_BUFFER]; // 检查目录,强制建立。

String zipedfilename = destdir + File.separator + entry.getName(); String zipedfilepath = FilenameUtils.getFullPath(zipedfilename); File zipedpath = new File(zipedfilepath); if (!zipedpath.exists()) zipedpath.mkdirs(); FileOutputStream fos = new FileOutputStream(zipedfilename); dest = new BufferedOutputStream(fos, DATA_BUFFER); while ((count = is.read(data, 0, DATA_BUFFER)) != -1) { dest.write(data, 0, count); } dest.flush(); dest.close(); is.close(); } } catch (Exception e) { e.printStackTrace(); } } }

smartupload.jar放的路径到底是什么?

1. 不用把jar文件里面的Class解压到WEB-INF/classes,先把这些删除了吧。

2. 下载servletAPI.jar 3. 设置你的在eclipse中,ClassPath。

JspSmartUpload上传组件有哪些特点

SmartUpload 是一个免费的上传下载组件,好像早已经停止开发了。

SmartUpload.jar:我找到的最好的一个jar包,对于编码为GBK的,完全支持中文名文件的上传与下载;但对于UTF-8的,中文名上传可以,但中文名下载还是乱码。

这个组件,小项目用用还行,对于大项目,不建议使用。

比较常用的有mons-fileupload等,而且许多框架都集成了上传下载功能,如Struts 1/ Struts 2 另外,注意一点:由于smartupload是把文件全部缓存到内存里,所以上传大文件或多文件时就有可能出错,建议一般不要超过20M,个数也不要太多

如何使用jspsmartupload

jspSmartUpload太小巧,问题很多,代码共享者很早就没有再维护次小项目,建议用monupload. 下载文件不用任何组件也可以,你只要给出正确的mime type即可。

为什么使用smartupload执行上传保存操作时用这句smart.save("upload")失败用smart.save("/upload")成功

你好,smart.save(“”)方法是将文件保存到指定目录,upload 表示当前请求文件的相对路径,/upload是表示web应用根目录下的upload目录。

只要能找到upload目录都是可以的。

星梦云-年中四川100G高防云主机月付仅60元,西南高防月付特价活动,,买到就是赚到!

官方网站:点击访问星梦云活动官网活动方案:机房CPU内存硬盘带宽IP防护流量原价活动价开通方式成都电信优化线路4vCPU4G40G+50G10Mbps1个100G不限流量210元/月 99元/月点击自助购买成都电信优化线路8vCPU8G40G+100G15Mbps1个100G不限流量370元/月 160元/月点击自助购买成都电信优化线路16vCPU16G40G+100G20Mb...

香港物理服务器 E5-2660v2 16G 500GSSD 增送20G防御 688/月 华纳云

#年终感恩活动#华纳云海外物理机688元/月,续费同价,50M CN2 GIA/100M国际大带宽可选,超800G 防御,不限流华纳云成立于2015年,隶属于香港联合通讯国际有限公司。拥有香港政府颁发的商业登记证明,作为APNIC 和 ARIN 会员单位,现有香港、美国等多个地区数据中心资源,百G丰富带宽接入,坚持为海内外用户提供自研顶级硬件防火墙服务,支持T B级超大防护带宽,单IP防护最大可达...

瓜云互联-美国洛杉矶高防CN2高防云服务器,新老用户均可9折促销!低至32.4元/月!

瓜云互联一直主打超高性价比的海外vps产品,主要以美国cn2、香港cn2线路为主,100M以内高宽带,非常适合个人使用、企业等等!安全防护体系 弹性灵活,能为提供简单、 高效、智能、快速、低成本的云防护,帮助个人、企业从实现网络攻击防御,同时也承诺产品24H支持退换,不喜欢可以找客服退现,诚信自由交易!官方网站:点击访问瓜云互联官网活动方案:打折优惠策略:新老用户购买服务器统统9折优惠预存返款活动...

smartupload为你推荐
人民日报谈扫码点餐餐厅扫码点餐系统流程是什么溢出隐藏overflow:hidden用在哪里?oncontextmenu鼠标右键很好用,但是左键一点反应也没有,请问是什么原因呢?最开放的浏览器网页浏览器有哪些啊?oracle索引什么是Oracle的函数索引?拓扑关系简述空间数据的拓扑关系及其对GIS数据处理和空间分析有何重要意义?jdk6java—JDK6,在SUN公司官网下载的链接,调度系统1.说明高级调度、中级调度和低级调度的基本含义。inode智能客户端我的电脑上inode智能客户端连接网络时,提示~服务器没有响应,请确认当前认证网卡已连接到合适的网rownumbersql server 2005中row_number怎么用
免费二级域名 南通服务器租用 德国vps 什么是二级域名 赵容 68.168.16.150 正版win8.1升级win10 win8升级win10正式版 699美元 双11秒杀 佛山高防服务器 网络空间租赁 php空间购买 免费智能解析 怎么建立邮箱 电信托管 跟踪路由命令 台湾google 阿里云官方网站 中国域名 更多