<%@ page contentType="text/html;charset=gbk" %>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.text.*,gbase.util.*,gbase.init.*"%>
<%@ page import="gbase.tool.upload.*" %>
<%@ include file="../../checkLogin.jsp" %>
<%
String vurl = request.getRequestURL().toString();
   
UploadBean theUploadBean=new UploadBean();

//附件上传到应用目录下的upload下
String newfilesavepath=application.getRealPath(File.separator+web_account+File.separator+"upload"+File.separator+"files");
//System.out.println("newfilesavepath:"+newfilesavepath);
//上传后的文件名（不带扩展名，扩展名UploadBean类自动取原上传文件名的扩展名）
SimpleDateFormat timeformat = new SimpleDateFormat("yyyyMMddHHmmss");
java.util.Date date = Calendar.getInstance().getTime();
String createdate = timeformat.format(date).toString();
String newFileName="newfile"+createdate;

//上传后的文件名(包括扩展名)
String returnFileName="";
 try{ 
   returnFileName=theUploadBean.uploadFile(request,newfilesavepath,newFileName);
   }
  catch(SecurityException e)
    {
    returnFileName="";
    System.out.println("file upload fail");
    }
if (!returnFileName.equals("")){
String root_savepath=application.getRealPath(File.separator+"upload"+File.separator+"files");
String from_file=newfilesavepath+"/"+returnFileName;
String to_file=root_savepath+"/"+returnFileName;
Copys theCopys=new Copys();   
theCopys.copy(from_file,to_file);

String filename="/upload/files/"+returnFileName;
out.println("<script language=javascript>");
out.print("parent.UploadSaved('");
out.print(filename+"','"+filename);
out.print("');");
out.println("</script>");

}
else
{
String message=(String)request.getAttribute("message");
out.println("<script language=javascript>");
out.print("parent.divProcessing.style.display='none';");
out.print("alert('");
out.print(message);
out.print("');");
out.print("parent.AbleItems();");
out.println("</script>");	
}
%>





