JSP File upload Download components (1)

Source: Internet
Author: User

Use Jspsmartupload to upload and download files

Jspsmartupload components have 4 main classes: File class, files class, request class, and Smartupload class

The Initialize method of the *smartupload class: This method is to upload and download the common method, his role is to perform the upload and download initialization work, must first execute. There are several prototypes, mainly using the following:

Public final void Initialize (Javax.serlvet.jsp.PageContext pagecontext)

Where PageContext is a JSP page built-in object

I. Basic steps for File upload:

1. Create a new Smartupload object

Smartupload su = new Smartupload ();

2. Initialization

Su.initialize (PageContext);

3. Set various upload limits

Su.setmaxfilesize (XXX);

Su.settotalmaxfilesize (XXX);

4. Set the file extensions that are allowed to be uploaded, such as

Su.setallowedfileslist ("Doc,txt");

5. Set the Forbidden file extension (, which indicates a file with no extension), as

Su.setdeniedfileslist ("Exe,bat,,");

6. Uploading Files

Su.upload ();

7. Save the file to the specified directory xxx

Su.save (XXX);

8. Determine if there is an upload file

Com.jspsmart.upload.File File = Su.getfiles (). GetFile (0);

If!file.ismissing () () {

......

}

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.