当前位置: 编程技术>java/j2ee
Apache FileUpload的两种上传方式介绍及应用
来源: 互联网 发布时间:2014-10-18
本文导语: 环境: tomcat5.6 commmons-fileupload-1.3.jar commmons-io-2.4.jar JSP 编码:UTF-8 临时文件夹:fileupload/tmp相对于网站根目录 上传文件保存位置:fileupload Traditional API上传方式 //fileload01.htm 代码如下: File to upload: to upload the file! //traditio...
环境:
tomcat5.6
commmons-fileupload-1.3.jar
commmons-io-2.4.jar
JSP
编码:UTF-8
临时文件夹:fileupload/tmp相对于网站根目录
上传文件保存位置:fileupload
Traditional API上传方式
//fileload01.htm
File to upload:
to upload the file!
//traditionalapi.jsp
-->
upload file done!
Streaming API上传方式
//fileupload02.htm
File to upload:
to upload the file!
//streamingapi.jsp
-->
upload file done!
Traditional API vs Streaming API
Streaming API上传速度相对较快。因为它是利用内存保存上传的文件,节省了传统API将文件写入临时文件带来的开销。
可参考:
http://stackoverflow.com/questions/11620432/apache-commons-fileupload-streaming-api
This page describes the traditional API of the commons fileupload library. The traditional API is a convenient approach. However, for ultimate performance, you might prefer the faster Streaming API.
http://commons.apache.org/proper/commons-fileupload/using.html
tomcat5.6
commmons-fileupload-1.3.jar
commmons-io-2.4.jar
JSP
编码:UTF-8
临时文件夹:fileupload/tmp相对于网站根目录
上传文件保存位置:fileupload
Traditional API上传方式
//fileload01.htm
代码如下:
File to upload:
to upload the file!
//traditionalapi.jsp
代码如下:
-->
upload file done!
Streaming API上传方式
//fileupload02.htm
代码如下:
File to upload:
to upload the file!
//streamingapi.jsp
代码如下:
-->
upload file done!
Traditional API vs Streaming API
Streaming API上传速度相对较快。因为它是利用内存保存上传的文件,节省了传统API将文件写入临时文件带来的开销。
可参考:
http://stackoverflow.com/questions/11620432/apache-commons-fileupload-streaming-api
This page describes the traditional API of the commons fileupload library. The traditional API is a convenient approach. However, for ultimate performance, you might prefer the faster Streaming API.
http://commons.apache.org/proper/commons-fileupload/using.html