<!--#include file="../../../inc/cms_admin.asp" -->
<!--#include file="../../../inc/cms_uploader.asp"-->
<%
    Dim up,uptype, json,upfolder,upAllowType,upMaxSize
	upfolder=getform("upfolder","both")
	uptype=getform("uptype","both")
	select case uptype
		case "image"	: upAllowType=imageExt	:	upMaxSize=imageMaxSize
		case "logo"		: upAllowType=imageExt	:	upMaxSize=imageMaxSize
		case "file" 	: upAllowType=fileExt	:	upMaxSize=fileMaxSize
		case "video"	: upAllowType=videoExt	:	upMaxSize=videoMaxSize		
		case else		: upAllowType=uptype	:	upMaxSize=fileMaxSize
	end select
	
    Set up = new Uploader
    up.MaxSize = upMaxSize
    up.AllowType = upAllowType
    up.ProcessForm()
    up.FileField = "form-data"
    up.SavePath = sitepath&upLoadPath&upfolder&"/"
    up.SaveFile()
	if uptype="image" and waterMark=1 then waterMarkImg up.FilePath
    Set json = jsObject()
    json("url") = up.FilePath
    json("ext") = getfileext(up.FilePath)
    json("state") = up.State
    json("title") =  replace(up.OriginalFileName,up.FileType,"")

     echo json.jsString()
    Function IsInArray(arr, elem)
        IsInArray = false
        For Each i In arr
            If i = elem Then IsInArray = true
        Next
    End Function
%>