td> form>
2. Read the table sheet
sssgetdata.jsp
<% @ Page ContentType = "Text / HTML; Charset = GBK"%> <% @ page language = "java" import = "com.jspsmart.upload. *"%> <% @ page import = "java.text.SIMPLEDATEFORMAT" %> <% @ Page Import = "java.io.file"%> <% @ page import = "java.util. *"%> <% @ page import = "javazoom.upload. *"%> <% @ Page import = "Uploadutilities.filemover"%> head> <% request.setcharacterencoding ("GBK") ; // Set the encoding format, do not need one by one. FileMover filemover = new filemover (); // You can also use the JSP: UseBean in an instance.
UploadBean upBean = new UploadBean (); MultipartFormDataRequest mrequest = null; Hashtable files = null; if (MultipartFormDataRequest.isMultipartFormData (request)) {mrequest = new MultipartFormDataRequest (request, null, 100 * 1024 * 1024, MultipartFormDataRequest.COSPARSER, "GBK" ); // Note that the encoding parameter String StT0 = MREQUEST.GETPARAMETER ("title"); " TITLE0 is:" stt0 " "); string stt1 = new String ( Stt0.GetBytes ("ISO-8859-1"), "GBK"); Out.println (" Title1 is:" stt1 " "); // This is used to test whether the Title parameter is correct. When debugging, add a sentence if (true) return; Files = MREQUEST.GETFILES ();
/ / Get the file name before modification string silverename = MREQUEST.GETPARAMETER ("OldFileName"); out.println ("SoldFileName:" soldfilename); string sWebrootPath = Request.getRealPath ("/"); // Get your web The root of the application. String spath = SWEBROOTPATH "attach"; int ifilecount = 0; string sserverfilename = ""; string slocalfilename = ""; // file gets IF ((files! = Null) | (! Files.isempty ())) {iFileCount = files.size (); UploadFile file = (UploadFile) files.get ( "attach"); sLocalFileName = file.getFileName (); out.println ( "sLocalFileName:" sLocalFileName); int ii = sLocalFileName.indexOf ( " "); // Take the suffix string sext = slocalfilename.substring (ii, slocalfilename.length ()); // Get no repetition name java.util.date dt = new java.util.date (System) .currentTimeMillis ()); SimpleDateFormat fmt = new SimpleDateFormat ( "yyyyMMddHHmmssSSS"); sServerFileName = fmt.format (dt); sServerFileName = sServerFileName sExt; // if the directory does not exist, a new File dir = new File (sPath ); If (! Dir.exists ()) {dir.mkdirs ();} UpBean.SetFolderstore (spath); // Set the directory UPBean.adduploadListener (filemover) you want to upload; // Add Filmover Monitor FileMover.setNewFileName (SserveFileName ); // Set file name upbean.store on the server (MREQUEST, "Attach"); // Upload Out.Println ("File Path IS" SPATH " SSERVERFILENA ME);
转载请注明原文地址:https://www.9cbs.com/read-62357.html
|