<!--#include file="../include/conn.jsp"-->
<!--#include file="../include/const.jsp"-->
<!--#include file="../include/upload.inc"-->
<!--#include file="../Include/char.jsp" -->
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="4">
<%
dim file_ext,uploadsize
file_ext="jpg,gif"
uploadsize=200

dim upload,file,formName,formPath,iCount,filename,fileExt
dim upNum
dim uploadsuc
dim Forumupload
dim ranNum
dim uploadfiletype
dim ss
upNum=request.cookies("0574tvUpload")("upNum")
if not isnumeric(upnum) then upnum=1

response.write "<FONT color=red>"&upNum&"</font>"

call upload_0()

sub upload_0()
set upload=new upfile_class ''建立上传对象
upload.GetDate (-1)

formPath=upload.form("filepath")

'在目录后加(/)
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
 	response.write "请先选择你要上传的文件　[ <a href=# onclick=history.go(-1)>重新上传</a> ]"
	response.end
	end if
 	
	if file.filesize>cint(uploadsize)*1024 then
 	response.write "文件大小超过了限制 "&uploadsize&"K　[ <a href=# onclick=history.go(-1)>重新上传</a> ]"
	response.end
	end if

	fileExt=lcase(right(file.filename,4))
	uploadsuc=false
	Forumupload=split(file_ext,",")
	for i=0 to ubound(Forumupload)
		if fileEXT="."&trim(Forumupload(i)) then
			uploadsuc=true
			exit for
		else
			uploadsuc=false
		end if
	next
	if fileEXT=".asp" and fileEXT=".asa" and fileEXT=".aspx" then
		uploadsuc=false
	end if
	if uploadsuc=false then
 	response.write "文件格式不正确　[ <a href=# onclick=history.go(-1)>重新上传</a> ]"
	response.end
	end if

	
	m_UserID = Request.Cookies("aspxnet")("CurUserID")
    formBigPath = formPath &"BigImages/"& m_UserID
	formSmallPath = formPath &"SmallImages/"& m_UserID

    Set fso = CreateObject("Scripting.FileSystemObject")
	If Not fso.FolderExists(Server.mappath(formBigPath)) Then
	  Set f = fso.CreateFolder(Server.mappath(formBigPath))
	  Set f=nothing
	end if
	Set fso = CreateObject("Scripting.FileSystemObject")
	If Not fso.FolderExists(Server.mappath(formSmallPath)) Then
	  Set f = fso.CreateFolder(Server.mappath(formSmallPath))
	  Set f=nothing
	end if

	set fso=nothing

	randomize : ranNum=int(90000*rnd)+10000
	filename_time = year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&fileExt
    Bigfilename = formBigPath&"/"&filename_time
	Smallfilename = formSmallPath&"/"&filename_time
	if file.FileSize>0 then         ''如果 FileSize > 0 说明有文件数据
	file.SaveToFile Server.mappath(Bigfilename)   ''保存文件
	
	call CreateSmallPic(Bigfilename,Smallfilename)
	for i=0 to ubound(Forumupload)
		if fileEXT="."&trim(Forumupload(i)) then
	     response.write "<script>parent.form1.hidFileName.value='"&filename_time&"';"&_
	                             "parent.form1.hidImageSize.value='"&file.FileSize&"';"
         response.write "</script>"
		exit for
		end if
	next
	iCount=iCount+1
	end if
	set file=nothing
next
set upload=nothing

Htmend iCount&" 个文件上传结束!"
end sub

sub CreateSmallPic(Bigfilename,Smallfilename)
 Dim Jpeg
 ' 建立实例
 Set Jpeg = Server.CreateObject("Persits.Jpeg")
 ' 打开目标图片
 Jpeg.Open Server.MapPath(Bigfilename)
 m_Height = jpeg.OriginalHeight
 m_Width = jpeg.OriginalWidth
 jpeg.Width = 180
 jpeg.Height = jpeg.OriginalHeight * jpeg.Width / jpeg.OriginalWidth
 Jpeg.Save Server.MapPath(Smallfilename)
 ' 注销对象
 Set Jpeg = Nothing
end Sub

sub HtmEnd(Msg)
	if upNum="" then upNum=1
	response.cookies("0574tvUpload")("upNum")=upNum+1
	'response.write "文件上传成功 [ <a href=# onclick=history.go(-1)>继续上传</a> ]"
	Response.write "文件上传成功,请提交！"
	response.end
end sub
%>
</body>
</html>