File Upload (I) form requirements for the Form of the file to be uploaded, there are two requirements: 1. The method applies post, that is, method = "Post ". 2. Add attributes: enctype = "multipart/form-Data". The following is an example of a form used to upload files:
<Form method = "Post" enctype = "multipart/form-Data" Action = "/jspsmartupload/upload. JSP "> <input type =" file "name =" myfile "> <input type =" Submit "> </form> |
(Ii) Upload Example 1: upload page upload.html This page provides a form that allows users to select the file to be uploaded and click "Upload" to perform the upload operation. The page source code is as follows:
<! -- File name: upload.html Author: vertical and horizontal software production center Yu Yiqi (zhsoft88@sohu.com) --> <! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en"> <HTML> |
2. Upload the file on the do_upload.jsp page. The page source code details the usage of the upload method, which will not be repeated here. The page source code is as follows:
<% -- File name: do_upload.jsp Author: Landscape software production center Yu Yiqi (zhsoft88@sohu.com) -- %> <% @ page contenttype = "text/html; charset = gb2312 "Language =" Java "Import =" Java. util. *, Com. jspsmart. upload. * "errorpage =" "%> <HTML> |