<!--#include file="../Include/upload_5xsoft.inc" -->
<%
Dim mUploadPath,mReturnForm,mReturnText
mUploadPath = Request.QueryString("UploadPath")
mReturnForm = Request.QueryString("ReturnForm")
mReturnText = Request.QueryString("ReturnText")

''将当前的日期和时间转为文件名
Function makefilename(fname)
  fname = now()
  fname = replace(fname,"-","")
  fname = replace(fname," ","") 
  fname = replace(fname,":","")
  fname = replace(fname,"PM","")
  fname = replace(fname,"AM","")
  fname = replace(fname,"上午","")
  fname = replace(fname,"下午","")
  makefilename=fname
End Function 
'GetExtendName
Function GetExtendName(FileName)
  dim ExtName
  ExtName = LCase(FileName)
  ExtName = right(ExtName,3)
  ExtName = right(ExtName,3-Instr(ExtName,"."))
  GetExtendName = ExtName
End Function
%>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="Images/Style.css" rel="stylesheet" type="text/css">
<Script language="javascript">
function mysubmit(theform)
{
    if(theform.file1.value=="")
    {
    alert("请点击浏览按钮，选择您要上传的jpg或gif文件!")
    theform.file1.focus;
    return (false);
    }
    else
    {
    str= theform.file1.value;
    strs=str.toLowerCase();
    lens=strs.length;
    extname=strs.substring(lens-4,lens);
    if(extname!=".jpg" && extname!=".gif")
    {
    alert("请选择jpg或gif文件!");
    return (false);
    }
    }
    return (true);
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" topmargin="0" leftmargin="0">
<table width="422" border="0" cellspacing="0" cellpadding="0" height="138">
  <tr>
  <form name="form1" method="post" action="UploadWindows.asp?action=upload&UploadPath=<%=mUploadPath%>&ReturnForm=<%=mReturnForm%>&ReturnText=<%=mReturnText%>&fname=<%=session("fname")%>" onsubmit="return mysubmit(this)" enctype="multipart/form-data" >
      <td width="439" valign="middle"> 
        <table width="98%" border="1" cellspacing="0" cellpadding="5" bordercolordark="#CCCCCC" bordercolorlight="#000000" height="43" align="center">
          <tr bgcolor="#CCCCCC"> 
            <td height="22" align="left" valign="middle" bgcolor="#f2f2f2"><table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr> 
                  <td width="84%"><b>文件上传：</b>
<%
if Request.Querystring("action")="upload" then
mUploadPath = Request.QueryString("UploadPath")
mReturnForm = Request.QueryString("ReturnForm")
mReturnText = Request.QueryString("ReturnText")
	if request.QueryString("fname")<>"" then
      delfname=server.mappath(mUploadPath)+"\"+Request.QueryString("fname")
      set TestFileObject=Server.Createobject("Scripting.FileSystemObject")
      if  TestFileObject.FileExists(delfname) then
         set NewFile=TestFileObject.getfile(delfname)
        Newfile.delete
      end if
	 end if
'-----------------------------------
dim upload,file,formName,formPath
set upload=new upload_5xSoft ''建立上传对象
formPath=mUploadPath'得到上传目录
 ''在目录后加(/)
if right(formPath,1)<>"/" then formPath=formPath&"/" 
for each formName in upload.file ''列出所有上传了的文件
 set file=upload.file(formName)  ''生成一个文件对象
FileName1=file.FileName
vfname = makefilename(now())
fname = vfname & "." & GetExtendName(file.FileName)
  filename=fname
if file.FileSize>300000 then
   response.write "&nbsp;&nbsp;&nbsp;&nbsp;<font color=red><b>上传失败，原因是文件太大。</b></font>"
   response.end
end if
 if file.FileSize>0 then         ''如果 FileSize > 0 说明有文件数据
  file.SaveAs Server.mappath(formPath&fname)   ''保存文件
 end if
 set file=nothing
next
set upload=nothing 
  Response.write "&nbsp;&nbsp;&nbsp;&nbsp;<font color=red><b>恭喜您！文件上传成功！</b></font>"
  Response.write "<script language='JavaScript'>opener.document."&mReturnForm + "." + mReturnText&".value='"&fname&"'</script>"
  Response.write "<script>window.close();</script>"
end if
%>

                  </td>
                  <td width="16%" align="right">[<a href="javascript:window.close()">关闭窗口</a>] 
                  </td>
                </tr>
              </table></td>
          </tr>
          <tr align="left" valign="middle" bgcolor="#eeeeee"> 
            <td bgcolor="#fcfcfc" height="16"> 注：只能上传.gif或.jpg类型的图片，且图片的容量必须在300k之内！</td>
          </tr>
          <tr align="center" valign="middle"> 
            <td align="left" id="upid"> 
              <table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr> 
                  <td height="7" align="center">文件名： 
                    <input type="file" name="file1"  value=""  style="width:310;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff"> 
                  </td>
                </tr>
              </table>
            </td>
          </tr>
          <tr align="center" valign="middle" bgcolor="#eeeeee"> 
            <td bgcolor="#fcfcfc" height="2"> 
              <input type="submit" name="Submit" value="· 提交 ·" style="width:80;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff">
              <input type="reset" name="Submit2" value="· 重执 ·" style="width:80;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff">
            </td>
          </tr>
        </table>
      </td>
    </form>
    </tr>
  </table>
</body>
</html>