Servlet Java Web Development (6) Upload downloads and mailings

Source: Internet
Author: User
Tags java web

Upload

Let's look at an example:

The code corresponding to the form

<form action= "<c:url value= '/upload1servlet '/>" method= "post" enctype= "Multipart/form-data" >   User name;<input type= "text" name= "username"/><br/>   photos:<input type= "file" Name= " Zhaopian "/><br/>  <input type=" Submit "value=" Upload "/></form>

Note Methods Post,enctype and type= "file"

Upload1servlet can pass through the print stream.

Content of the HTTP protocol

In the header, followed by Content-type:multipart/form-data, followed by a row of boundary=------------------------d232olxdk22l

Or something like a complex string. After the header ends there are

Then there is the binary content of the uploaded file,

Servlet Java Web Development (6) Upload downloads and mailings

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.