You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.2 KiB

<%@ page contentType="text/html;charset=gb2312" language="java" import="com.jspsmart.upload.*"%>
<%@ page import="com.jspsmart.upload.*"%>
<%@ page import="java.util.*"%>
<%
String path = request.getContextPath();
%>
<%
String newFile1Name=null;
String file_name=null;
SmartUpload mySmartUpload = new SmartUpload();
//<2F><>ʼ<EFBFBD><CABC><EFBFBD>ϴ<EFBFBD>
mySmartUpload.initialize(pageContext);
//ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD><D8B4><EFBFBD><EFBFBD>ļ<EFBFBD>
try
{
//mySmartUpload.setAllowedFilesList("jpg,Jpg,JPG,GIF,gif,Gif,png");
mySmartUpload.upload();
}
catch (Exception e)
{
//out.println("<script language=javascript>alert('<27>ϴ<EFBFBD><CFB4><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'); history.back(-1);</script>");
//return;
}
try
{
com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(0);
if (myFile.isMissing())
{
out.println("<script language=javascript>alert('<27><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>ͼƬ<CDBC><C6AC>'); history.back(-1);</script>");
return;
}
else
{
int file_size = myFile.getSize(); //ȡ<><C8A1><EFBFBD>ļ<EFBFBD><C4BC>Ĵ<EFBFBD>С (<28><>λ<EFBFBD><CEBB>b)
file_name=myFile.getFileName();
System.out.println("<22>ļ<EFBFBD><C4BC><EFBFBD>С<EFBFBD><D0A1>"+file_size+"<22>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ƣ<EFBFBD>"+file_name);
//if (file_size > 10*1024*1024)
//{
//out.println("<script language=javascript>alert('<27>ϴ<EFBFBD>ͼƬ<CDBC><C6AC>СӦ<D0A1><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>10K~1M֮<4D>䣡'); history.back(-1);</script>");
//return;
//}
//else
//{
newFile1Name=new Date().getTime()+file_name.substring(file_name.indexOf("."));
System.out.println("<22><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ƣ<EFBFBD>"+newFile1Name);
String saveurl = request.getSession().getServletContext().getRealPath("upload");
saveurl = saveurl+"/"+newFile1Name;
myFile.saveAs(saveurl, mySmartUpload.SAVE_PHYSICAL);
// }
}
}
catch (Exception e)
{
e.toString();
}
%>
<script language="javascript">
var str=location.toString()
var Result=((((str.split('?'))[1]).split('='))[1]);
//window.opener.Form1(Result).focus();
window.parent.document.getElementById(Result).value="upload/<%= newFile1Name%>";
//window.opener=null;
document.write("<22>ϴ<EFBFBD><CFB4>ɹ<EFBFBD>");
//window.close();
</script>