File Upload and file download

Source: Internet
Author: User

necessary prerequisites for uploading 1.1 files:

A, provide form form ,method must be post

b, the form form enctype must be multipart/form-data

C, provide input type= "file" class of the upload field

1.2enctype Properties

function: Notifies the server of the request body MIME type. (Request message header:content-type effect is consistent)

Optional values:

application/x-www-form-urlencoded ( default ):

Body: name=admin&password=123

Server fetch data: String name = Request.getparameter ("name");

Multipart/form-data:

The server gets the data: therequest.getparameter (String) method gets the specified form field character content, but the file upload form is no longer the character content, but the byte content, so the invalidation

File Upload: Parses the contents of each part of the request body.

        Request.setcharacterencoding ("UTF-8");                 = Request.getinputstream ();         int Len;         byte New byte [1024x768];                  while (len = Sis.read (b))! =-1) {            // output upload file contents            System.out.println (new String (b,0, Len));        }                Sis.close ();

File Upload and file download

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.