Servlet 2.5
To upload
The first requirement for the form
->method = "POST"
->enctype= "Mulitpart/form-data" Default value is "application/x-www-urlencoded"
-><input= "file" name= "filename must be given" >
Requirements for Servlets
Because it's a multi-component
So a series of methods such as Request.getparamter () cannot be used
Need to use Request.getinputstream ();
The parsing of flows requires the use of
Commons-fileupload
Using uploads takes three steps
Create a factory
Creating a parser
The parser is used to parse the request object to get list<fileitem>
==============================================================
Support for Servlet 3.0 uploads
Upload steps
Get part
Request.getpart ("Field name")
getContentType gets the MIME type of the file
GetName gets the name of the form item is not a file name
GetHeader (String header) Gets the value of the specified header
GetSize get the size of the upload file
getInputStream get the contents of the uploaded file
Write (String filename) to save the uploaded file to the specified path
Servlet 3.0 support for uploads