Please select word document
<% @ page import = "java.io.File"%>
<% @ page language = "java" import = "java.util. *, com.jspsmart.upload. *" pageEncoding = "utf-8"%>
<%
try {
mySmartUpload.initialize (pageContext);
mySmartUpload.service (request, response);
mySmartUpload.upload ();
/ / get the first upload the file name
String fn = mySmartUpload.getFiles (). getFile (0). getFileName ();
/ / String word_file = new File (getServletContext (). getRealPath ("/"). toString () + "UploadWord /" + fn); automatically get url not complete
/ / session.setAttribute ("WordFile", word_file) ;/ / added to the session
/ / session.setAttribute ("WordFile", "E :/ / Program Files / SoftwareDocument / Apache Software Foundation / Tomcat 6.0/webapps/AnalyticWord/UploadWord /" + fn) ;
/ / the uploaded file to the specified folder
mySmartUpload.save ("UploadWord /");
out.print (" has been successfully uploaded files , please see here , see whether the file uploaded successfully
");
out.print (" page mode to view Word documents ");
} catch (Exception e) {
session.setAttribute ("WordFile", "");
out.print (" Upload Word documents fail , Please try again ");
}
%>
没有评论:
发表评论