1 | <%@ CodePage=65001 Language="VBScript"%>
|
---|
2 | <%
|
---|
3 | Option Explicit
|
---|
4 | Response.Buffer = True
|
---|
5 | %>
|
---|
6 | <!--
|
---|
7 | * FCKeditor - The text editor for internet
|
---|
8 | * Copyright (C) 2003-2006 Frederico Caldeira Knabben
|
---|
9 | *
|
---|
10 | * Licensed under the terms of the GNU Lesser General Public License:
|
---|
11 | * http://www.opensource.org/licenses/lgpl-license.php
|
---|
12 | *
|
---|
13 | * For further information visit:
|
---|
14 | * http://www.fckeditor.net/
|
---|
15 | *
|
---|
16 | * "Support Open Source software. What about a donation today?"
|
---|
17 | *
|
---|
18 | * File Name: upload.asp
|
---|
19 | * This is the "File Uploader" for ASP.
|
---|
20 | *
|
---|
21 | * File Authors:
|
---|
22 | * Frederico Caldeira Knabben (fredck@fckeditor.net)
|
---|
23 | -->
|
---|
24 | <!--#include file="config.asp"-->
|
---|
25 | <!--#include file="io.asp"-->
|
---|
26 | <!--#include file="class_upload.asp"-->
|
---|
27 | <%
|
---|
28 |
|
---|
29 | ' This is the function that sends the results of the uploading process.
|
---|
30 | Function SendResults( errorNumber, fileUrl, fileName, customMsg )
|
---|
31 | Response.Write "<script type=""text/javascript"">"
|
---|
32 | Response.Write "window.parent.OnUploadCompleted(" & errorNumber & ",""" & Replace( fileUrl, """", "\""" ) & """,""" & Replace( fileName, """", "\""" ) & """,""" & Replace( customMsg , """", "\""" ) & """) ;"
|
---|
33 | Response.Write "</script>"
|
---|
34 | Response.End
|
---|
35 | End Function
|
---|
36 |
|
---|
37 | %>
|
---|
38 | <%
|
---|
39 |
|
---|
40 | ' Check if this uploader has been enabled.
|
---|
41 | If ( ConfigIsEnabled = False ) Then
|
---|
42 | SendResults "1", "", "", "This file uploader is disabled. Please check the ""editor/filemanager/upload/asp/config.asp"" file"
|
---|
43 | End If
|
---|
44 |
|
---|
45 | ' The the file type (from the QueryString, by default 'File').
|
---|
46 | Dim resourceType
|
---|
47 | If ( Request.QueryString("Type") <> "" ) Then
|
---|
48 | resourceType = Request.QueryString("Type")
|
---|
49 | Else
|
---|
50 | resourceType = "File"
|
---|
51 | End If
|
---|
52 |
|
---|
53 | ' Create the Uploader object.
|
---|
54 | Dim oUploader
|
---|
55 | Set oUploader = New NetRube_Upload
|
---|
56 | oUploader.MaxSize = 0
|
---|
57 | oUploader.Allowed = ConfigAllowedExtensions.Item( resourceType )
|
---|
58 | oUploader.Denied = ConfigDeniedExtensions.Item( resourceType )
|
---|
59 | oUploader.GetData
|
---|
60 |
|
---|
61 | If oUploader.ErrNum > 1 Then
|
---|
62 | SendResults "202", "", "", ""
|
---|
63 | Else
|
---|
64 | Dim sFileName, sFileUrl, sErrorNumber, sOriginalFileName, sExtension
|
---|
65 | sFileName = ""
|
---|
66 | sFileUrl = ""
|
---|
67 | sErrorNumber = "0"
|
---|
68 |
|
---|
69 | ' Map the virtual path to the local server path.
|
---|
70 | Dim sServerDir
|
---|
71 | sServerDir = Server.MapPath( ConfigUserFilesPath )
|
---|
72 | If ( Right( sServerDir, 1 ) <> "\" ) Then
|
---|
73 | sServerDir = sServerDir & "\"
|
---|
74 | End If
|
---|
75 |
|
---|
76 | If ( ConfigUseFileType = True ) Then
|
---|
77 | sServerDir = sServerDir & resourceType & "\"
|
---|
78 | End If
|
---|
79 |
|
---|
80 | Dim oFSO
|
---|
81 | Set oFSO = Server.CreateObject( "Scripting.FileSystemObject" )
|
---|
82 |
|
---|
83 | ' Get the uploaded file name.
|
---|
84 | sFileName = oUploader.File( "NewFile" ).Name
|
---|
85 | sExtension = oUploader.File( "NewFile" ).Ext
|
---|
86 | sOriginalFileName = sFileName
|
---|
87 |
|
---|
88 | Dim iCounter
|
---|
89 | iCounter = 0
|
---|
90 |
|
---|
91 | Do While ( True )
|
---|
92 | Dim sFilePath
|
---|
93 | sFilePath = sServerDir & sFileName
|
---|
94 |
|
---|
95 | If ( oFSO.FileExists( sFilePath ) ) Then
|
---|
96 | iCounter = iCounter + 1
|
---|
97 | sFileName = RemoveExtension( sOriginalFileName ) & "(" & iCounter & ")." & sExtension
|
---|
98 | sErrorNumber = "201"
|
---|
99 | Else
|
---|
100 | oUploader.SaveAs "NewFile", sFilePath
|
---|
101 | If oUploader.ErrNum > 0 Then SendResults "202", "", "", ""
|
---|
102 | Exit Do
|
---|
103 | End If
|
---|
104 | Loop
|
---|
105 |
|
---|
106 | If ( ConfigUseFileType = True ) Then
|
---|
107 | sFileUrl = ConfigUserFilesPath & resourceType & "/" & sFileName
|
---|
108 | Else
|
---|
109 | sFileUrl = ConfigUserFilesPath & sFileName
|
---|
110 | End If
|
---|
111 |
|
---|
112 | SendResults sErrorNumber, sFileUrl, sFileName, ""
|
---|
113 |
|
---|
114 | End If
|
---|
115 |
|
---|
116 | Set oUploader = Nothing
|
---|
117 | %> |
---|