Upload images using the commons-fileupload-1.3.1.jar Toolkit

Source: Internet
Author: User

The dependency package for the commons-fileupload-1.3.1.jar toolkit is commons-io-2.2.jar (fileuploaddepends on commons Io, so make sure you have the version mentioned on thedependenciespage in your classpath before continuing .)

 

Commons-fileupload-1.3.1.jar

The Wiki on the official website explains: commons-fileuploadmakes it easy to add robust, high-performance, file upload capability to yourservlets and Web applications. That is, the files are supported by servlets native. How to use it in struts2 can only be learned through the official website docs.

 

Demo provided on the official website

Http://commons.apache.org/proper/commons-fileupload/streaming.html

 

I found struts2 demo http://www.zuidaima.com/share/1833981853305856.htm here

 

After learning the struts2 demo, I solved the problem.

The following is my code:











After successful:



It is worth noting that after a file is uploaded, the file extension must be determined before it is uploaded. The file upload directory is configured in struts. XML, and the file information is transmitted from the JSP file to the action.



Upload images using the commons-fileupload-1.3.1.jar Toolkit

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.