Third, the file upload (1) Form form for uploading files, two requirements: 1. Method Apply POST, Method = "POST". 2, increase the attribute: encType = "multipart / form-data" Below is an example of a Form form for uploading files:
Page source code as follows: <- filename:! Upload.html Author: vertical and horizontal software production center rain also odd (zhsoft88@sohu.com) -> file upload title> Upload file selection p> 1, div> 2, div> 3, div> 4, div> td> div> td> tr> table> form> body> html> 2, upload processing page do_upload.jsp This page performs file upload operations. The usage of the upload method is described in detail in the page source code, and details will not be described here. Page source code as follows: <% - filename: do_upload.jsp Author: vertical and horizontal software production center rain also odd (zhsoft88@sohu.com) -%> <% @ page contentType = "text / html; charset = gb2312" language = "Java" Import = "java.util. *, com.jspsmart.upload. *" ErrorPage = ""%> file upload processing page title> head> <% // New a SmartUPload Object Smartupload Su = New SmartUPload (); // Upload Initialization Su.initialize (PageContext) ; // Set up the upload limit // 1. Restrict the maximum length of each upload file. // Su.setMaxFileSize (10000); // 2. Restrict the length of the total upload data. // Su.SettotalMaxFileSize (20000); // 3. Set the file that allows upload (by extension restrictions), only the DOC, TXT file is allowed. // Su.setAllowedFileSlist ("DOC, TXT"); // 4. Set the file that prohibits uploading (by extension restrictions), prohibiting uploading files with EXE, BAT, JSP, HTM, HTML extensions and no expansion Name file. // Su.SetdeniedFileSlist ("EXE, BAT, JSP, HTM, HTML,"); // Upload file Su.upload (); // Save all of the upload files to the specified directory int count = Su.Save ("/ UPLOAD "); Out.println (Count " file upload success! "); // Use the Request object to obtain parameters of parameters Out.println (" test = " su.getRequest (). getParameter (" test " ) " "); // upload files one by one to extract information, and save the file. 转载请注明原文地址:https://www.9cbs.com/read-130020.html9cbsNew Post(0)
Page source code as follows: <% - filename: do_upload.jsp Author: vertical and horizontal software production center rain also odd (zhsoft88@sohu.com) -%> <% @ page contentType = "text / html; charset = gb2312" language = "Java" Import = "java.util. *, com.jspsmart.upload. *" ErrorPage = ""%>