[ Index ]
 

Code source de FCKeditor 2.4

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/editor/filemanager/upload/asp/ -> upload.asp (source)

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


Généré le : Sun Feb 25 15:28:05 2007 par Balluche grâce à PHPXref 0.7