Rev 1075 | Blame | Last modification | View Log | RSS feed
<%@ CodePage=65001 Language="VBScript"%><%Option ExplicitResponse.Buffer = True%><!--* FCKeditor - The text editor for internet* Copyright (C) 2003-2006 Frederico Caldeira Knabben** Licensed under the terms of the GNU Lesser General Public License:* http://www.opensource.org/licenses/lgpl-license.php** For further information visit:* http://www.fckeditor.net/** "Support Open Source software. What about a donation today?"** File Name: upload.asp* This is the "File Uploader" for ASP.** File Authors:* Frederico Caldeira Knabben (fredck@fckeditor.net)--><!--#include file="config.asp"--><!--#include file="io.asp"--><!--#include file="class_upload.asp"--><%' This is the function that sends the results of the uploading process.Function SendResults( errorNumber, fileUrl, fileName, customMsg )Response.Write "<script type=""text/javascript"">"Response.Write "window.parent.OnUploadCompleted(" & errorNumber & ",""" & Replace( fileUrl, """", "\""" ) & """,""" & Replace( fileName, """", "\""" ) & """,""" & Replace( customMsg , """", "\""" ) & """) ;"Response.Write "</script>"Response.EndEnd Function%><%' Check if this uploader has been enabled.If ( ConfigIsEnabled = False ) ThenSendResults "1", "", "", "This file uploader is disabled. Please check the ""editor/filemanager/upload/asp/config.asp"" file"End If' The the file type (from the QueryString, by default 'File').Dim resourceTypeIf ( Request.QueryString("Type") <> "" ) ThenresourceType = Request.QueryString("Type")ElseresourceType = "File"End If' Create the Uploader object.Dim oUploaderSet oUploader = New NetRube_UploadoUploader.MaxSize = 0oUploader.Allowed = ConfigAllowedExtensions.Item( resourceType )oUploader.Denied = ConfigDeniedExtensions.Item( resourceType )oUploader.GetDataIf oUploader.ErrNum > 1 ThenSendResults "202", "", "", ""ElseDim sFileName, sFileUrl, sErrorNumber, sOriginalFileName, sExtensionsFileName = ""sFileUrl = ""sErrorNumber = "0"' Map the virtual path to the local server path.Dim sServerDirsServerDir = Server.MapPath( ConfigUserFilesPath )If ( Right( sServerDir, 1 ) <> "\" ) ThensServerDir = sServerDir & "\"End IfIf ( ConfigUseFileType = True ) ThensServerDir = sServerDir & resourceType & "\"End IfDim oFSOSet oFSO = Server.CreateObject( "Scripting.FileSystemObject" )' Get the uploaded file name.sFileName = oUploader.File( "NewFile" ).NamesExtension = oUploader.File( "NewFile" ).ExtsOriginalFileName = sFileNameDim iCounteriCounter = 0Do While ( True )Dim sFilePathsFilePath = sServerDir & sFileNameIf ( oFSO.FileExists( sFilePath ) ) TheniCounter = iCounter + 1sFileName = RemoveExtension( sOriginalFileName ) & "(" & iCounter & ")." & sExtensionsErrorNumber = "201"ElseoUploader.SaveAs "NewFile", sFilePathIf oUploader.ErrNum > 0 Then SendResults "202", "", "", ""Exit DoEnd IfLoopIf ( ConfigUseFileType = True ) ThensFileUrl = ConfigUserFilesPath & resourceType & "/" & sFileNameElsesFileUrl = ConfigUserFilesPath & sFileNameEnd IfSendResults sErrorNumber, sFileUrl, sFileName, ""End IfSet oUploader = Nothing%>