<!--#include file="UpLoad_Class.asp"-->
<!--#include file="Mo.Lib.Json.asp"-->
<!--#include file="../db.asp"-->
<%

	'系统变量
	Set rs = Server.CreateObject("ADODB.Recordset")
	rs.Open "Select * From [jinke_set] where id=1 ",conn,1,1
	uploadtype = rs("uploadtype")
	if isnull(uploadtype) or uploadtype="" then uploadtype="gif/jpg/png/bmp/doc/docx/xls/xlsx/ppt/pptx/pdf/rar/zip/txt"
	uploadsize = rs("uploadsize")
	if isnull(uploadsize) or uploadsize="" then uploadsize="10"
	rs.Close
	Set rs = Nothing

    uploadtype=Replace(uploadtype,"/",";/")
    uploadtype="/"&uploadtype
	uploadtype=Replace(uploadtype,"/","*.")
	
	
dim upload,dopost,file,savpath,code,data
set upload = new AnUpLoad
set code = MoLibJson.new()
dopost = Request("dopost")
chat = Request("chat")
'if dopost="image" then
'upload.Exe = "*.jpg;*.gif;*.png;*.jpeg"
'upload.MaxSize = cint(uploadsize) * 1024 * 1024 'M
'else
upload.Exe = uploadtype '上传类型
upload.MaxSize = CDbl(uploadsize) * 1024 * 1024 'M 大小限制
'end if
Upload.charset="utf-8" 
upload.GetData()
if upload.ErrorID>0 then 
	code.put "code",1
	code.put "msg","上传失败"&upload.Description
	set data = code.put("data")
	data.put "src",""
	data.put "name",""
else

if chat="1" then
	savepath = "/upload/Chat/"&year(now())&"-"&month(now())
else
	savepath = "/upload/Files/"&year(now())&"-"&month(now())
end if 
	
	
	for each frm in upload.forms("-1")
		code.put "code",1
		code.put "msg","上传失败"& frm & "=" & upload.forms(frm)
		set data = code.put("data")
		data.put "src",""
		data.put "name",""
	next
	
	set file = upload.Files("file")
	if file.isfile then
		result = file.saveToFile(savepath,0,true)
		if result then
			code.put "code","0"
			code.put "msg","上传成功"
			set data = code.put("data")
			data.put "src",""&savepath & "/" & file.filename
			data.put "name",file.LocalName	
			'"文件'" & file.LocalName & "'上传成功,保存位置'" & server.MapPath(savepath & "/" & file.filename) & "',文件大小" & file.size & "字节<br />"
		else
			code.put "code",1
			code.put "msg","上传失败"&file.Exception
			set data = code.put("data")
			data.put "src",""
			data.put "name",""
		end if
	end if			
	'response.Write code.toString()
	set file = upload.Files_Muti("file",1)
	if file.isfile then
		result = file.saveToFile(savepath,1,true)
		if result then
			code.put "code","0"
			code.put "msg","上传成功"
			set data = code.put("data")
			data.put "src",""&savepath & "/" & file.filename
			data.put "name",file.LocalName	
			'"文件'" & file.LocalName & "'上传成功,保存位置'" & server.MapPath(savepath & "/" & file.filename) & "',文件大小" & file.size & "字节<br />"
		else
			code.put "code",1
			code.put "msg","上传失败"&file.Exception
			set data = code.put("data")
			data.put "src",""
			data.put "name",""
		end if
	end if
	
	'Response.Write "成功保存的文件个数:" & Upload.QuickSave("file1",savepath) & "个"
end if
response.Write code.toString()
set upload = nothing
%>
