<%@Language=VBScript%>
<%
Option Explicit
Response.Buffer = True
%>
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<TITLE></TITLE>
</HEAD>
<style>
BODY {
	FONT-SIZE: 9pt; 
}
</style>
<BODY>
<%
Dim FormPath,FilenameFront
FormPath = "../Theme/"	''定义上传路径
FilenameFront=request.querystring("filename")
Upload_0

Sub Upload_0()
	Dim Upload
	Dim File,FormName,FileName,FileExt,SaveFile
	Dim CountSize,UseTime
	CountSize = 0
	Set Upload = Server.CreateObject("DvFile.Upload")	''建立上传对象
	Upload.InceptFileType = "gif"		''上传文件类型限制 以 “,” 号分隔
	Upload.MaxSize = 1024000									''限制大小 :-1为无限,单位 B
	Upload.Install										''加载上传数据
	If Upload.Err > 0 Then	''错误参数
		''输出错误信息
		Select Case Upload.Err
			Case 1 : Response.Write Upload.Description	''请先选择你要上传的文件
			Case 2 : Response.Write Upload.Description	''文件大小超过了限制 "&Upload.MaxSize/1024&"K　
			Case 3 : Response.Write Upload.Description	''非法的上传类型
			Case 4 : Response.Write Upload.Description	''所上传的类型受系统限制
			Case 5 : Response.Write Upload.Description	''参数有误，上传意外中止
		End Select
		Response.Write "　[ <a href=# onclick=history.go(-1)>重新上传</a> ]"
		Exit Sub
	Else
		'If Upload.Count>1 Then Response.Write "上传个数超过限制" : Exit Sub
		'FormPath = Upload.Form("filepath")		''从表单filepath获取上传路径
		 For Each FormName In Upload.File		''列出所有上传了的文件
			Set File = Upload.File(FormName)	''生成一个文件对象
			FileExt	= File.FileExt				''获取上传文件后缀名
			FormPath = FormatPath(FormPath)		''格式化上传路径
 			FileName = FilenameFront&"."&FileExt 		''定义文件名
			SaveFile = FormPath & FileName
 			If File.FileSize>0 Then				''如果 FileSize > 0 说明有文件数据
				Upload.SaveToFile Server.Mappath(SaveFile),FormName   ''保存文件
				'Upload.FileData(FormName)		''获取单个文件内容数据
				''输出信息：
				Response.write "<div style=""color:green;font-size:12px;"">模板上传成功！请点击确定按纽保存</div>"
				Response.Write("<SCRIPT>parent.addusertheme.themefilename.value='"&FileNameFront&"'</SCRIPT>")
 			End If
 			Set File=Nothing
		Next
	End If
	Set Upload=Nothing
End Sub

Function FormatPath(Path)
	FormatPath = Replace(Path,Chr(0),"")
End Function
%>
</BODY>
</HTML>