文件上传--Smartupload上传组件【下】
2013-03-03 09:39
507 查看
批量上传
从之前可以发现,不管上传多少个文件,都可以通过getFiles()方法取得,那么现在就可以利用操作完成多个文件的上传,这种操作就是文件的批量上传。
一个实例看一下批量上传是怎么上传的。
运行后结果如下:
上传后看一下upload文件夹中的确有了3中图片(如下图),而且这3张图片都是同一张图片,但是命名确实不一样的,在Smartupload上传组件【中】中我们都讲过了。
、
到目前为止,文件上传就学到这个地方,需要注意的是:文件的上传还有比较常用的是fileUpload上传组件,fileUpload是很复杂的一种上传,牵扯到的东西比较多,一般应用与框架开发中,比如Structs 等框架。相比较来说,Smartupload上传应用与jsp开发中,而且比较简单。
从之前可以发现,不管上传多少个文件,都可以通过getFiles()方法取得,那么现在就可以利用操作完成多个文件的上传,这种操作就是文件的批量上传。
一个实例看一下批量上传是怎么上传的。
Smart_03.html <html> <head> <title>WEB开发</title> </head> <body> <form action="smart_03.jsp" method="post" enctype="multipart/form-data"> 照片1:<input type="file" name="pic1"><br> 照片2:<input type="file" name="pic2"><br> 照片3: <input type="file" name="pic3"><br> <input type="submit" value="上传"><br> <input type="reset" value="重置"> </form> </body> </html>
Smart_03.jsp <%@ page language="java" contentType="text/html" pageEncoding="utf-8"%> <%@ page import="com.jspsmart.upload.*" %> <%@ page import="simpl.IPTimeStamp"%> <html> <head> <title>WEB开发项目</title> </head> <body> <% request.setCharacterEncoding("utf-8"); %> <% SmartUpload smart=new SmartUpload(); smart.initialize(pageContext);// 初始化上传操作 smart.upload(); //上传准备 String name=smart.getRequest().getParameter("uname"); //实例化IPTimeStamp对象 IPTimeStamp its=new IPTimeStamp(request.getLocalAddr()); for(int x=0;x<smart.getFiles().getCount();x++){ String ext=smart.getFiles().getFile(x).getFileExt();//取得文件后缀 String fileName=its.getIPTimeRand()+"."+ext;//拼凑文件名称 smart.getFiles().getFile(x).saveAs(getServletContext().getRealPath("/") +"upload"+java.io.File.separator+fileName);//保存文件 } %> </body> </html>
运行后结果如下:
上传后看一下upload文件夹中的确有了3中图片(如下图),而且这3张图片都是同一张图片,但是命名确实不一样的,在Smartupload上传组件【中】中我们都讲过了。
、
到目前为止,文件上传就学到这个地方,需要注意的是:文件的上传还有比较常用的是fileUpload上传组件,fileUpload是很复杂的一种上传,牵扯到的东西比较多,一般应用与框架开发中,比如Structs 等框架。相比较来说,Smartupload上传应用与jsp开发中,而且比较简单。
相关文章推荐
- 在jsp中使用smartupload组件上传文件ggg
- 文件上传—jspSmartUpload组件
- 使用smartupload组件实现jsp+jdbc上传下载文件实例解析
- 文件上传--Smartupload上传组件【上】
- 用ASPSmartUpload组件实现ASP文件上传
- 在jsp中使用smartupload组件上传文件
- smartupload组件上传文件
- 使用jspSmartUpload组件进行文件上传、下载
- jspsmartupload组件实现单个或多个文件上传(下)
- JSP SMARTUPLOAD组件:上传文件时同时获取表单参数
- java使用smartupload组件实现文件上传的方法
- 使用jspSmartUpload组件进行文件上传、下载
- 使用jspSmartUpload组件进行文件上传、下载
- 使用JspSmartUpload组件上传文件
- SmartUpload组件实现文件上传和下载
- 在项目中使用SmartUpload组件可以进行文件的上传和下载操作
- 项目开发技巧(四):使用JspSmartupload实现文件上传下载(一):JspSmart之upload组件源码及使用
- 采用jspSmartUpload组件进行文件的上传
- 采用jspSmartUpload组件进行文件的上传
- 用jspSmartUpload组件实现文件上传、下载