<!--#include file="../Include/Char.asp" -->
<!--#include file="../Include/Conn.asp" -->
<!--#include file="../Include/upload_5xsoft.inc" -->

<%
if trim(Request.Cookies("UserID")) = "" or trim(Session("UserID"))=""  THEN
     Response.Redirect("Login.asp")
	 Response.End()
   end if
   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
 

 m_ID = request.cookies("UserID")
if Request.ServerVariables("REQUEST_METHOD") = "POST" then 

 dim upload,file,formName,formPath,iCount
 set upload=new upload_5xSoft ''建立上传对象

  m_Title = CheckStr(Upload.form("Title"))
  'if m_Title = "" then
    ' call msgbox("对不起,文字说明不能为空",1)
	' Response.end()
  'end if
  
 formPath="UploadImages"
 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 <>".jpg" then
      call MsgBox("对不起，图片类型出错，请问重新上传",1)
	  response.end
   end if

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

        'response.Cookies("UploadImage")=filename
		'REsponse.write m_UserName
		'response.end
		f_type = CheckStr(Upload.form("f_type"))
		f_info =CheckStr(Upload.form("f_info"))
		dates= CheckStr(Upload.form("textfield"))
    SQL="INSERT INTO citycard_Image(F_Title,F_Image,F_UserName,F_Date,F_Time,f_info,f_type) VALUES('"&m_Title&"','"&filename&"','"&m_ID&"','"&dates&"','"&time&"','"&f_info&"','"&f_type&"')"
    Conn.Execute SQL  
Response.Write "<script language=""javascript"">opener.location.reload()</script>"
		
 iCount=iCount+1
 set file=nothing
 end if
Next


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

  
sub HtmEnd(Msg)
 set upload=nothing
end sub	 
 
 %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>图片上传</title>
<link href="../css/Style.css" rel="stylesheet" type="text/css"><link href="../css/Menu.css" rel="stylesheet" type="text/css"><link href="../css/aCardList.css" rel="stylesheet" type="text/css"><SCRIPT src="../js/029bxw.js" type=text/javascript></SCRIPT>
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
</head>

<body >
<table width="453" height="115" border="0" cellpadding="4" cellspacing="0" bgcolor="#FFFFFF">
  <form name="form1" enctype="multipart/form-data" method="post" action="">
    <tr> 
      <td width="320" height="44">请选择<font color="#FF0000">jpg,gif</font>图像,且小于200K<br>
        商品名称：
        <input name="Title" type="text" id="Title" size="16">
        <select name="f_type" id="f_type">
          <option value="新品发布" selected>新品发布</option>
          <option value="推荐商品">推荐商品</option>
        </select>
        <br>
        发布时间：
        <input name="textfield" type="text" value="<%=formatdatetime(now(),2)%>" size="10">
        请按<span class="style1">2006-01-01</span>此格式填写<br>
      商品简介：(可选项)<br>
      <textarea name="f_info" cols="40" rows="3" id="f_info"></textarea></td>
      <td width="114" rowspan="3" align="center">
	  <%
	  If filename<>"" then
	    Response.write  "<img src='UploadImages/"&filename&"' width='110' height='106'>"
	  else
	    Response.write "未上传"
	  End if
	  %>
	  </td>
    </tr>
    <tr> 
      <td> <input type="file" name="file"> <input type="submit" name="Submit" value="上　传"> 
      </td>
    </tr>
    <tr>
      <td align="center" valign="bottom"><input type="button" name="Submit2" onClick="window.close()" value="关　闭"></td>
    </tr>
  </form>
</table>
</body>
</html>
