upload.asp
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:3k
源码类别:

OA系统

开发平台:

C#

  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. ' This is the function that sends the results of the uploading process.
  29. Function SendResults( errorNumber, fileUrl, fileName, customMsg )
  30. Response.Write "<script type=""text/javascript"">"
  31. Response.Write "window.parent.OnUploadCompleted(" & errorNumber & ",""" & Replace( fileUrl, """", """" ) & """,""" & Replace( fileName, """", """" ) & """,""" & Replace( customMsg , """", """" ) & """) ;"
  32. Response.Write "</script>"
  33. Response.End
  34. End Function
  35. %>
  36. <%
  37. ' Check if this uploader has been enabled.
  38. If ( ConfigIsEnabled = False ) Then
  39. SendResults "1", "", "", "This file uploader is disabled. Please check the ""editor/filemanager/upload/asp/config.asp"" file"
  40. End If
  41. ' The the file type (from the QueryString, by default 'File').
  42. Dim resourceType
  43. If ( Request.QueryString("Type") <> "" ) Then
  44. resourceType = Request.QueryString("Type")
  45. Else
  46. resourceType = "File"
  47. End If
  48. ' Create the Uploader object.
  49. Dim oUploader
  50. Set oUploader = New NetRube_Upload
  51. oUploader.MaxSize = 0
  52. oUploader.Allowed = ConfigAllowedExtensions.Item( resourceType )
  53. oUploader.Denied = ConfigDeniedExtensions.Item( resourceType )
  54. oUploader.GetData
  55. If oUploader.ErrNum > 1 Then
  56. SendResults "202", "", "", ""
  57. Else
  58. Dim sFileName, sFileUrl, sErrorNumber, sOriginalFileName, sExtension
  59. sFileName = ""
  60. sFileUrl = ""
  61. sErrorNumber = "0"
  62. ' Map the virtual path to the local server path.
  63. Dim sServerDir
  64. sServerDir = Server.MapPath( ConfigUserFilesPath )
  65. If ( Right( sServerDir, 1 ) <> "" ) Then
  66. sServerDir = sServerDir & ""
  67. End If
  68. If ( ConfigUseFileType = True ) Then
  69. sServerDir = sServerDir & resourceType & ""
  70. End If 
  71. Dim oFSO
  72. Set oFSO = Server.CreateObject( "Scripting.FileSystemObject" )
  73. ' Get the uploaded file name.
  74. sFileName = oUploader.File( "NewFile" ).Name
  75. sExtension = oUploader.File( "NewFile" ).Ext
  76. sOriginalFileName = sFileName
  77. Dim iCounter
  78. iCounter = 0
  79. Do While ( True )
  80. Dim sFilePath
  81. sFilePath = sServerDir & sFileName
  82. If ( oFSO.FileExists( sFilePath ) ) Then
  83. iCounter = iCounter + 1
  84. sFileName = RemoveExtension( sOriginalFileName ) & "(" & iCounter & ")." & sExtension
  85. sErrorNumber = "201"
  86. Else
  87. oUploader.SaveAs "NewFile", sFilePath
  88. If oUploader.ErrNum > 0 Then SendResults "202", "", "", ""
  89. Exit Do
  90. End If
  91. Loop
  92. If ( ConfigUseFileType = True ) Then
  93. sFileUrl = ConfigUserFilesPath & resourceType & "/" & sFileName
  94. Else
  95. sFileUrl = ConfigUserFilesPath & sFileName
  96. End If
  97. SendResults sErrorNumber, sFileUrl, sFileName, ""
  98. End If
  99. Set oUploader = Nothing
  100. %>