<!--#include file="inc.asp"-->
<!--#include file="ydzq.asp"-->
<!--#include file="upload.inc"-->


<%saytk=2
Call head()
Call saycarda("WAP2.0上传道具")
Server.ScriptTimeOut = 1800
dim constPath,mypath
mypath=server.mappath("uploadd.asp")
constPath=replace(mypath,"uploadd.asp","")
CONTSE=request("CONTSE")
dim TP
TP=request.querystring("TP")
dim upload,oFile,formName,SavePath,filename,fileExt,oFileSize,sizes
dim EnableUpload
dim arrUpFileType
dim ranNum
dim msg,FoundErr,MaxFileSize
MaxFileSize="1024"'最大上传文件，以KB为单位
msg=""
FoundErr=false
EnableUpload=true
dim strMonth,strDay
dim kk,reshow,pwidth,pheight,up
dim userid,username,sessionid,photoContent,photoview

kk=0

	set upload=new upfile_class ''建立上传对象
	upload.GetData(104857000600)   '取得上传数据,限制最大上传100M
	if upload.err > 0 then  '如果出错
		select case upload.err
			case 1
				msg= "请先选择你要上传的文件！"
			case 2
				msg= "你上传的文件总大小超出了最大限制（100M）"
		end select
		'showWML()
		response.end
	end if

  SavePath = "images/"	


for each formName in upload.file 
		set ofile=upload.file(formName)  '生成一个文件对象	
		upfilename=ofile.FileName		
		oFileSize=ofile.filesize	
		sizes=cstr(round(oFileSize/1024))		
		fileExt=lcase(ofile.FileExt)
   
		if fileEXT="asp" or fileEXT="asa" or fileEXT="aspx" or fileEXT="exe" or fileEXT="bat" or fileEXT="dll" then
		 EnableUpload=false
		end if
		if EnableUpload=false then
			msg="这种文件类型不允许上传:asp|asa|aspx|exe|bat|..."
			FoundErr=true
			'showWML()
		  response.end
		end if

			if fileExt="gif" or fileExt="jpg" or fileExt="jpeg" or fileExt="png" then
else
  Call Error("图片格式错误！")
end if

		if oFileSize>(MaxFileSize*1024) then
      msg="文件大小超过了限制，最大只能上传" & CStr(MaxFileSize) & "K的文件！"
			FoundErr=true
			'showWML()
		  response.end
		end if
		
		
		if FoundErr<>true then
			randomize
			ranNum=int(900*rnd)+100
			
			strMonth=month(now)
			if len(strMonth)=1 then
				strMonth="0"&strMonth
			end if
			strDay=day(now)
			if len(strDay)=1 then
				strDay="0"&strDay
			end if
			
			'--------------------
			
			filename=SavePath&year(now)&strMonth&strDay&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt
      'response.write getRealPath(FileName)
      dim realpath
      realpath="/bbs/"&filename
      'realpath=getRealPath(filename)
      ' response.write realpath
      '建立文件夹
      'setCreateFolder(realpath)
			
			ofile.SaveToFile Server.mappath(""&realpath&"")   '保存文件   

'--------看空间支持与否------------		
dim wi,hi,w,h,hhi
'命名方式
dim photoname,ranNums
randomize
ranNums=int(90000*rnd)+10000
photoname=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNums&"."&fileExt
        w=90 '定义相册的列表缩略图的大小,以宽为标准
                dim j
		set j=server.createobject("persits.jpeg")
		j.open server.mappath(realpath)
		wi=j.width
		hi=j.height
if wi>W then 
hhi=wi/W
               j.width=w
               j.height=w+5
end if
		j.save server.mappath("photo/"&photoname)
		j.close
		set j=nothing
dim upfileid
set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select top 1 ID from upfile order by id desc",conn,1,1
upfileid=rs("ID")
rs.close
set rs=nothing
 

	END IF
		set file=nothing
	
next
    
	set upload=nothing
	    msg="您的相片已成功上传！<br/>"

		 conn.close
set conn=Nothing
Dim photonamee
If photoname<>"" Then
photonamee=photoname
Else
photonamee=realpath
End if

response.write "<a href='checkshow.asp?saytk="&saytk&"&amp;CONTSE="&CONTSE&"&amp;sid="&sid&"&amp;urltou=/bbs/photo/"&photonamee&"'>返回继续修改资料</a><br/>"					

%>
<%=msg%>
<a href="show.asp?saytk=<%=saytk%>&amp;sid=<%=sid%>">[我的小屋]</a>
<%Call headsay()%>