<!--#include file="UpLoad_Class.asp"-->
<!--#include file="Mo.Lib.Json.asp"-->
<!--#include file="../md5.asp" -->
<!--#include file="../db.asp"-->
<%
loginkey = ""
if session("Login_Uid")<>"" then
Set rslog = server.createobject("ADODB.Recordset")
rslog.open "select * from [jinke_user] Where uid = " & session("Login_Uid"),conn,1,1
If rslog.recordcount > 0 Then
uid = rslog("uid")
upassword = rslog("upassword")
ugroup = rslog("ugroup")
ulevel = rslog("ulevel")
loginkey = Mid(md5(Mid(UCASE(md5(uid&upassword&ugroup&ulevel,32)),3,10),16),2,12)
end If
rslog.close
Set rslog = Nothing
end if
If session("Login_Sionid")=loginkey And session("Login_Name")<>"" Then
else
response.write "{ ""code"": ""1"" , ""msg"": ""登录验证失败，请重新登录"" }"
response.end
end if


'系统变量
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")

upload.Exe = uploadtype '上传类型
upload.MaxSize = CDbl(uploadsize) * 1024 * 1024 'M 大小限制

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
%>
