📄 upload.jsp~1~
字号:
<%@ page contentType="text/html; charset=GB2312" %>
<%@ page language="java" import="com.jspsmart.upload.*,common.Business"%>
<jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" />
<HTML>
<BODY BGCOLOR="white">
<H1>上传图片页</H1>
<HR>
<%
// Variables
int count=0;
// Initialization
mySmartUpload.setDenyPhysicalPath(false);
mySmartUpload.setForcePhysicalPath(true);
mySmartUpload.initialize(pageContext);
mySmartUpload.setTotalMaxFileSize(10000000);
// Upload
try {
mySmartUpload.upload();
// Save the files with their original names in the virtual path "/upload"
// if it doesn't exist try to save in the physical path "/upload"
count = mySmartUpload.save("/upload");
if (count>0)
{
String picPath=mySmartUpload.getFiles().getFile(0).getFileName();
Business bus=new Business();
String relpath=application.getRealPath("upload.jsp");
relpath=bus.getPath(relpath);
String oldname=relpath+"\\upload\\"+picPath;
String newName=bus.getNewName(oldname);
if (bus.renameTo(oldname,newName))
{
System.out.println("-----successful!---------");
}
else
{
System.out.println("--------failed------------");
}
String filename=bus.getName(newName);
session.setAttribute("picPath",filename);
System.out.println("picPath:"+filename+"---------------");
}
// Save the files with their original names in the virtual path "/upload"
// count = mySmartUpload.save("/upload", mySmartUpload.SAVE_VIRTUAL);
// Display the number of files uploaded
out.println(count + " file(s) uploaded.");
} catch (Exception e) {
out.println(e.toString());
}
%>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -