<%@ 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();
theUploadBean.setMAXFILESIZE(102400);
//附件上传到应用目录下的upload下
String newfilesavepath=application.getRealPath(File.separator+web_account+File.separator+"upload"+File.separator+"files");

//上传后的文件名（不带扩展名，扩展名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+web_account+File.separator+"my_cms_images");
String from_file=newfilesavepath+"/"+returnFileName;
String to_file=root_savepath+"/logo.jpg";
Copys theCopys=new Copys();   
theCopys.copy(from_file,to_file);

String filename="/my_cms_images/logo.jpg";
%>
<%@ page contentType="text/html;charset=gbk" %>
<HTML>
<HEAD>
<TITLE>上传成功</TITLE>
<link rel="stylesheet" type="text/css" href="site.css">
</head>
<script language="javascript">
		function returnPath (){
			var obj = window.opener.document.getElementById("real_url");
			if (obj != null){
				obj.value = real_path.innerHTML;	
			}
		}
</script>
<BODY bgColor=menu topmargin=15 leftmargin=15 onUnload="javascript: returnPath();">
<CENTER>
  <table width=100%>
    <tr> 
      <td align="center"><br/><br/>
        <LEGEND align="center" >上传成功.</LEGEND>
        <br/>
        <div id="real_path" style="display:none"><%=filename%></div>
        </td>
    </tr>
    <tr> 
      <td  align="center"> 
    	<input type=button value='   关闭   ' onclick="window.close();"></td>
    </tr>
  </table>
</center>
</body>
</html>
		
<%	
	}else{
%>
<%@ page contentType="text/html;charset=gbk" %>
<html>
<head>
  <title>上传文件出错</title>
<script type="text/javascript" src="popup.js"></script>
</head>
<body onLoad="javascript: window.resizeTo(400, 200);">
<div class="title">上传文件出错</div>

<form action="/info_admin/upload.jsp" method="post" enctype="multipart/form-data">
  <table border="0" width="100%" >
    <tbody>
      <tr> 
        <td  align="right">出错原因:</td>
        <td align="left"><%=(String)request.getAttribute("message")%></td>
      </tr>
    </tbody>
  </table>
<table width="100%">
 <tr>
  <td valign="bottom"  align="center">
	<input name="" type="button" value="关闭" onClick="javascript: window.opener=null;window.close();">
	
  </td>
 </tr>
</table>
</form>
</body>
</html>
<%		
	}
%>





