<!--#include file="../inc/conn2.asp"-->
<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="eims.css">
</head><!--#include file="cookies.asp"-->
<!--#include file="../inc/UpLoad_Class.asp"-->
<div class='menu'>&nbsp;相册</div>
<p>&nbsp;<a href="WedList.asp">【返回婚庆列表】</a></p>
<%
eims = "Photo"
eTable = Prefix&eims
ListUrl = eims&"List.asp?eims="&eims
EditUrl = eims&"Edit.asp?eims="&eims

eType=trim(request("eType"))
Action = Trim(Request("Action"))
TypeID=Int(request("TypeID"))

if TypeID>0 then

If Action="Del" Then
Conn.Execute("delete from [eims_Photo] where ItemID="&Int(Request("ItemID")))
End If

if request("Action")="exe" then
dim upload
set upload = new AnUpLoad

Upload.MaxSize=1024*picMax '设置最大上传限制,按字节计；默认为不限制
Upload.Exe=picType '设置合法扩展名,以|分割

savey=year(now)
savem=month(now) : if len(savem)=1 then savem="0"&savem
savex=savey&savem
attached = SiteDir&"attached/"&savex '文件保存路径/年月保存

Upload.Charset="utf-8" '设置文本编码，默认为gb2312
Upload.openProcesser=false '禁止进度条功能，如果启用，需配合客户端

upload.GetData()
if upload.ErrorID>0 then 
	response.Write upload.Description
else
	dim file,savpath
	savepath = attached
	set file = upload.files("file1")
	if not(file is nothing) then
		result = file.saveToFile(savepath,0,true)
		if result then
			msg = attached&"/"&file.filename '文件名
			fileSize = int(file.size/1024) '大小
		else
			msg = file.Exception
		end if
	response.write "上传成功！文件大小："&fileSize&" KB <a href='?eType="&eType&"&TypeID="&TypeID&"'>[重新上传]</a>"
	else
	response.write "上传失败<a href='?eType="&eType&"&TypeID="&TypeID&"'>[重新上传]</a>"
	end if
end if
set upload = nothing
'插入到数据表中
conn.execute("insert into [eims_Photo] (eType,TypeID,Photo) values ('Wed','"&TypeID&"','"&msg&"')")
end if
%>
<form action="?Action=exe&eType=<%=eType%>&TypeID=<%=TypeID%>" method="post" enctype="multipart/form-data"> 
<input type="file" name="file1" />&nbsp;<input type="submit" value="上传" />
</form>
<div class="iPic">
<%
'response.write eType&"-"&TypeID
Set Rs=Server.CreateObject("Adodb.RecordSet")
Rs.Open "Select * From [eims_Photo] where TypeID="&TypeID&" order by ItemID desc",Conn,1,1
while not Rs.eof
%>
<li><img src="<%=rs("Photo")%>">
<span><a href="?Action=Del&TypeID=<%=TypeID%>&ItemID=<%=rs("ItemID")%>" onClick="return confirm('确定要删除吗？')" >删除</a></span></li>
<%
Rs.Movenext
wend
Rs.Close:Set Rs=Nothing
%>
</div>
<% end if %>

</body></html>
<%Call CloseConn()%>
