<%@ codepage ="936" %>
<!-- #include file = "../mycartconn/conn.asp" -->
<!-- #Include File = "Function.asp" -->
<!-- #Include File = "upload.inc" -->
<%
function MakedownName()
dim fname
Randomize
fname = now()
fname = replace(fname,"-","")
fname = replace(fname," ","") 
fname = replace(fname,":","")
fname = replace(fname,"PM","")
fname = replace(fname,"AM","")
fname = replace(fname,"上午","")
fname = replace(fname,"下午","")
fname = int(fname) + int((100-1+1)*Rnd + 1)
MakedownName=fname
end function 

'生成文件夹子程序
sub add_myfso (wjj)
set myfso = Server.CreateObject("Scripting.FileSystemObject")
If myfso.FolderExists(server.MapPath(wjj))=False Then
	myfso.CreateFolder server.MapPath(wjj)
End If
set myfso=nothing
end sub

bh=year(date) & right("00"&month(date),2) & right("00"&day(date),2)
formPath="../UploadFiles/"&bh
add_myfso(formPath)


If Request.ServerVariables("CONTENT_LENGTH") <> 0 Then
  set upload=new upload_5xsoft   '建立上传对象
  formName = "filename"
  for each formName in upload.file 

	set file=upload.file(formName)

	if file.FileSize>0 then
		if file.filesize>1024*1024 then
			response.write "0"
			response.end
		else
			upflag=false
			select case trim(LCase(right(file.FileName,4)))
			case ".gif"
				upflag=true
			case ".jpg"
				upflag=True
			case ".png"
				upflag=true
			case ".jpeg"
				upflag=true
			case else
				upflag=false
			end Select

			if instr(lcase(file.FileName),".asp")>0 or instr(lcase(file.FileName),".asa")>0 or instr(lcase(file.FileName),".aspx")>0 then
				upflag=false
			end If

			if not upflag then
				response.write "0"
				response.end
			Else
				oldFileName=file.FileName
				FileName=MakedownName()&"."&mid(file.FileName,InStrRev(file.FileName, ".")+1)
				file.SaveAs Server.mappath(formPath&"/"&FileName)

				FileSeverPath=Server.mappath(formPath&"/"&FileName)
				if HX_ScanFile(FileSeverPath) then
					CheckFile FileSeverPath,True 
					response.write "0"
				end If
				
			end if
		end if
	else
		response.write "0"
		response.end
	end if
	set upload=nothing 
	set file=Nothing
	Response.write myurl&"/UploadFiles/"&bh&"/"&FileName&""
	Next
End IF
%>
