<!-- #include file="setup.asp" -->
<!--#include FILE="inc/upfile.asp"-->

<%
if Request.Cookies("username")=empty then
error2("您还未登录社区")
end if

if Request("menu")="up" then


ftime=""&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&""

select case selectup
case ""
error2("对不起，本系统关闭文件上传功能")
case "SA-FileUp"

Set upl = Server.CreateObject("SoftArtisans.FileUp")

select case ""&upl.ContentType&""
case "application/octet-stream"
error2("未知文件格式")
case "image/gif"
types="gif"
case "image/pjpeg"
types="jpg"
case "image/bmp"
types="bmp"
case "image/x-png"
types="png"
case "text/plain"
types="txt"
case "audio/mid"
types="mid"
case "application/msword"
types="doc"
case "application/x-zip-compressed"
types="zip"
case "application/x-shockwave-flash"
types="swf"
end select

filename="images/upfile/"&ftime&"."&types&""

if upl.TotalBytes > int(MaxFile) then error2("文件大小不得超过 "&int(MaxFile/1024)&" KB\n当前的文件大小为 "&int(upl.TotalBytes/1024)&" KB")


if types="gif" or types="jpg" or types="png" or types="bmp" then
img="[img]"&filename&"[/img]"

elseif types="swf" or types="txt" or types="mid" or types="doc" or types="zip" then
img="[img]images/affix.gif[/img][url="&filename&"]相关附件[/url]"
else
error2("对不起，本服务器只支持GIF、JPG、BMP、PNG、TXT、MID、DOC、ZIP、SWF格式的文件\n不支持 "&upl.ContentType&" 格式的文件")
end if


upl.SaveAs Server.mappath(""&filename&"")

sql="insert into upfile(username,filename,types,len) values ('"&Request.Cookies("username")&"','"&ftime&"','"&types&"','"&upl.TotalBytes&"')"
conn.Execute(SQL)

set upl=nothing

case "FSO"
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

set FileUP=new Upload_file
FileUP.GetDate(-1)
formPath="images/upfile/"
set file=FileUP.file("file")
filename=formPath&ftime&"."&file.FileExt

if file.filesize > int(MaxFile) then error2("文件大小不得超过 "&int(MaxFile/1024)&" KB\n当前的文件大小为 "&int(file.filesize/1024)&" KB")


types=LCase(file.FileExt)

if types="gif" or types="jpg" or types="bmp" or types="png" then
img="[img]"&filename&"[/img]"

elseif types="swf" or types="txt" or types="mid" or types="doc" or types="zip" or types="rar" or types="torrent" then
img="[img]images/affix.gif[/img][url="&filename&"]相关附件[/url]"
else
error2("对不起，本服务器只支持GIF、JPG、BMP、PNG、TXT、MID、DOC、ZIP、SWF、RAR、torrent格式的文件\n不支持 "&types&" 格式的文件")
end if

file.SaveToFile Server.mappath(filename)


set FileUP=nothing

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
end select
response.write "<script>document.oncontextmenu = new Function('return false')</script><body topmargin=0  rightmargin=0  leftmargin=0><SCRIPT>parent.form.content.value+='\n"&img&"'</SCRIPT>"
response.write "<table cellpadding=0 cellspacing=0 width=100%  height=100% class=a4><tr><td><a target=_blank href="&filename&">"&cluburl&""&filename&"</a> [<a href=upfile.asp>继续上传</a>] </td></tr></table>"
responseend

else

%>
<script>if(top==self)document.location='';</script>
<body topmargin=0  rightmargin=0  leftmargin=0>

<form enctype=multipart/form-data method=post action=upfile.asp?menu=up>
<table cellpadding=0 cellspacing=0 width=100% class=a4>
<tr><td>
<td><input type=file style=FONT-SIZE:9pt name=file size=60> <input style=FONT-SIZE:9pt type="submit" value=" 上 传 " name=Submit></td></tr></table><%

end if
%>