<!--#include file="../Include/Char.jsp" -->
<!--#include file="../Include/Conn.jsp" -->
<!--#include file="../Include/upload_5xsoft.inc" -->
<%
  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 

function GetExtendName(FileName)
dim ExtName
ExtName = LCase(FileName)
ExtName = right(ExtName,3)
ExtName = right(ExtName,3-Instr(ExtName,"."))
GetExtendName = ExtName
end function
%>


<%
if CheckStr(Trim(Request("uploadimage"))) = "OK" then

      ID = Request.Cookies("UserID")
      SET rs=server.createobject("adodb.recordset")
      SQL="SELECT * FROM  CityCard_League WHERE CompanyID ="&ID
      rs.Open SQL,conn,1,1 
      if rs("logo")<>"" then
	          delfname=server.mappath("UpLoadLogoImages") & "\"&Rs("logo") 
              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,iCount
set upload=new upload_5xSoft ''建立上传对象


 formPath="UpLoadLogoImages"
 if right(formPath,1)<>"/" then formPath=formPath&"/" 
  iCount=0

for each formName in upload.file ''列出所有上传了的文件
 set file=upload.file(formName)  ''生成一个文件对象
 
 if file.FileSize <= 0 then    ''如果 FileSize > 0 说明有文件数据
   call MsgBox("对不起，请选择上传图片",1)
   response.end
 else
   
   last=lcase(right(file.filename,4))
   if last <>".gif" and last <>".jpg" then
      call MsgBox("对不起，图片类型出错，请问重新上传",1)
	  response.end
   end if

   FileName1=file.FileName
   vfname = makefilename(now())
   fname = vfname & "." & GetExtendName(file.FileName)
   filename=fname  
	 
  file.SaveAs Server.mappath(formPath&fname)   ''保存文件

   response.Cookies("UploadImage")=filename

 
  
        iCount=iCount+1
        set file=nothing
        end if
       Next


      set upload=nothing  ''删除此对象
      Htmend iCount&" 个文件上传结束!"
end if

sub HtmEnd(Msg)
 set upload=nothing
end sub


%>


<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body bgcolor="f5f5f5" leftmargin="0" topmargin="0">
<% if Request.cookies("UploadImage")="" then%>
<form action="?uploadImage=OK" method="post" enctype="multipart/form-data" name="form1">
  <input type="file" name="file">
  <font size="2">
  <input type="submit" name="Submit" value="上传">
  <font color="#FF0000">Jpg、Gif 100*130</font></font> 
</form>
<%else
   Response.write "上传成功 <a href='Rest_UploadImage.jsp' >重新上传</a>"
end if%>
</body>
</html>
