<%@LANGUAGE='VBSCRIPT' CODEPAGE='65001'%>
<%
option explicit
Response.Expires = -1
Response.Charset= "UTF-8"
Server.ScriptTimeout = 600
%>
<!-- #include file="fileUploadClass.asp" -->
<!-- #include file="config.asp" -->
<!-- #include file="json.asp" -->
<%
SaveFiles()

Function SaveFiles
    Dim Upload, json, i

    Set Upload = New fileUploadClass
    Upload.Save(UPLOAD_PATH)

	If Err.Number <> 0 Then Exit Function
    If Right(UPLOAD_URL, 1) <> "/" Then UPLOAD_URL = UPLOAD_URL & "/"

	Set json = New jsonParser
	Response.ContentType = "application/json"

	For Each i in Upload.UploadedFiles.keys
		With json.data
			.Add "fileUrl", UPLOAD_URL & Upload.UploadedFiles(i).FileName
			.Add "fileName", Upload.UploadedFiles(i).FileName
			.Add "fileSize", Upload.UploadedFiles(i).Length
		End With
		Response.Write json.JSONoutput()
    Next
End Function
%>