<!--#include file="../inc.asp"-->
<!--#include file="../ydzq1.asp"-->
<!--#include file="../upload.inc"-->
<!--#include file="conn.asp"-->
<%	
call body(1,"礼品管理")
' 忽略所有错误
on error resume next
Server.ScriptTimeOut = 1800
dim constPath,mypath
mypath=server.mappath("WAP2_Upfileph.asp")
constPath=replace(mypath,"WAP2_Upfileph.asp","")
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=""&bbsupsize&""'最大上传文件，以KB为单位
msg=""
FoundErr=false
EnableUpload=true
dim strMonth,strDay
dim kk,reshow,pwidth,pheight,up
dim userid,username,sessionid,photoContent,photoview,paycent,paycent1
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 = "mig/"	
	photoContent=trim(upload.form("photoContent"))
	photoContent1=trim(upload.form("photoContent1"))
	photoview=clng(upload.form("photoview"))
	paycent=clng(upload.form("paycent"))
	paycent1=clng(upload.form("paycent1"))
	if photoContent="" then
	Call Error("名称不能为空，请返回重试！")
	end if
	if len(photoContent)>10 then
	Call Error("名称最多10字，请返回重试！")
	end if
	if photoview="" or paycent="" or paycent1="" then
	Call Error("各项不能为空，请返回重试！")
	end if
	if paycent=0 or paycent=0 then
	Call Error("价格或数量不能为0，请返回重试！")
	end if

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=getRealPath(filename)
	' response.write realpath
	'建立文件夹
	setCreateFolder(realpath)
	
	ofile.SaveToFile Server.mappath(realpath)   '保存文件   
	
	
if upfilename<>"" then
	'将文件写入数据库
	
	set rs=Server.CreateObject("ADODB.Recordset")
	rs.open"select * from txt",Giftsconn,1,2
	rs.addnew
	rs("nane")= photoContent  '名称
	rs("url")=realpath  '路径
	rs("Price")=paycent  '价格
	rs("Categories")=photoview  '类别
	rs("Amount")=paycent1  '数量
	rs("txta")= photoContent1
	rs.update
	rs.close
	set rs=nothing
       
END IF
END IF
	set file=nothing
next
	set upload=nothing

	conn.close
	set conn=nothing
	Giftsconn.close
set Giftsconn=nothing

%>
成功上传！<br/><a href='admin.asp?ve=<%=ve%>&amp;id=<%=photoview%>&amp;sid=<%=sid%>'>返回</a><br/>
<a href="photofile.asp?ve=<%=ve%>&amp;sid=<%=sid%>">继续上传</a><br/>
<%call body(2,"")%>