-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload_xml.asp
72 lines (70 loc) · 2.18 KB
/
upload_xml.asp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!--#include file="vbscript.asp"-->
<%
DIM content_type: content_type=Request.ServerVariables("HTTP_ACCEPT")
Response.CharSet = "ISO-8859-1"
'ON ERROR RESUME NEXT'
'IF INSTR(content_type,"xml") THEN
'Response.ContentType = "text/xml"
DIM file_location, file_name
file_name = Request.ServerVariables("HTTP_FILE_NAME")
parent_folder = Request.ServerVariables("HTTP_PARENT_FOLDER")
DIM xmlDoc
Set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load(Request)
xmlDoc.setProperty "SelectionLanguage", "XPath"
xmlDoc.setProperty "SelectionNamespaces", "xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"""
Randomize
DIM ext
IF (TypeName(xmlDoc.selectSingleNode("/xsl:*"))<>"Nothing") THEN
ext="xsl"
ELSEIF (TypeName(xmlDoc.selectSingleNode("/*[namespace-uri()='']"))<>"Nothing") THEN
ext="xml"
ELSE
ext="xml"
END IF
user_file_name="user_"&session("user_id")&"_"&REPLACE(REPLACE(REPLACE(NOW(),":",""),"/","")," ","_")&"_"& Rnd &"."&ext
IF (file_name="") then
file_name = user_file_name
END IF
IF parent_folder<>"" THEN
parent_folder = server.MapPath("\")&"\"&parent_folder&"\"
ELSE
parent_folder = server.MapPath("\")&"\"
END IF
file_location=parent_folder&file_name
set fso=CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(parent_folder) Then
CreateFolder parent_folder 'fso.CreateFolder (parent_folder)
End If
Response.ContentType = "application/json"
xmlDoc.save file_location
%>
{
"fileName":"<%= file_location %>"
<%
IF NOT(file_name = user_file_name) THEN
user_file_name="user_"&session("user_id")&"_"&REPLACE(REPLACE(REPLACE(NOW(),":",""),"/","")," ","_")&"_"& Rnd &"."&ext
parent_folder = server.MapPath("\")&"\..\sessions\save\"
If Not fso.FolderExists(parent_folder) Then
CreateFolder parent_folder
End If
file_location=parent_folder&user_file_name
xmlDoc.save file_location
END IF
%>
"userFileName":"<%= file_location %>"
<%
IF Err.Number<>0 THEN
ErrorDesc=Err.Description
%>
, "status": "exception"
, "message": "<%= REPLACE(REPLACE(ErrorDesc, "[Microsoft][ODBC SQL Server Driver][SQL Server]", ""), """", "\""") %>"
<%
response.end
ELSE
%>
, "status": "success"
<%
END IF %>
}