JavaWeb- file upload foundation

When uploading files, forms need to be prepared to do:

1) Request embodiment POST: <form action = "uploadServlet" method = "post" ...>

2) form field using the file: <input type = "file" name = "file" />

 

About enctype:

  > Application / x-www-form-urlencoded: The default value of the form attribute enctype. This coding scheme uses a limited set of characters when using a non-letters and numbers, must be "% HH" instead of (H representative of a hexadecimal number). For high-volume text or binary data comprises non-ASCII characters, this encoder can not meet the requirements.

  > Multipart / form-data: form the set enctype = "multipart / form-data" attribute of the transmission data in binary form

 

3) server:

1> can not use request.getParamter () request for information, etc., not obtain, since the coding mode request has been replaced multipart / form-data, binary manner submit a request message.

 

2> can use to obtain input stream, but is not recommended

 

3> specific use commons-fileupload components to complete the file upload operation.

Guess you like

Origin www.cnblogs.com/yangHS/p/11221337.html