File upload-use packaged rack packages

Source: Internet
Author: User

Uploading of files

As mentioned earlier, the file upload and download, all through the operation of IO stream to achieve, so the following directly write a simple example of file upload function

First step: Import the jar package

Yes, and the download is a package

Step two: Setting up the foreground page

Requires that the form must be a multipart form, and that the submission must be post, with at least one file upload tag, which must have the name attribute, or it will be meaningless

      

            //get File Upload Download objectSmartupload su =Newsmartupload (); //InitializeSu.initialize ( This. Getservletconfig (), request,response); Try {            //get the uploaded contentsu.upload (); //save in Server root directorySu.save ("/"); } Catch(smartuploadexception e) {//TODO auto-generated Catch blockE.printstacktrace (); }

This jar package can also set the file upload format, size, etc., you can also set the name of the file save, etc.

  

File upload-use packaged rack packages

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.