2
* FCKeditor - The text editor for internet
3
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
5
* Licensed under the terms of the GNU Lesser General Public License:
6
* http://www.opensource.org/licenses/lgpl-license.php
8
* For further information visit:
9
* http://www.fckeditor.net/
11
* "Support Open Source software. What about a donation today?"
13
* File Name: class_upload.asp
14
* These are the classes used to handle ASP upload without using third
15
* part components (OCX/DLL).
18
* NetRube (netrube@126.com)
21
'**********************************************
22
' File: NetRube_Upload.asp
23
' Version: NetRube Upload Class Version 2.1 Build 20050228
25
' Email: NetRube@126.com
27
' Comments: The code for the Upload.
28
' This can free usage, but please
29
' not to delete this copyright information.
30
' If you have a modification version,
31
' Please send out a duplicate to me.
32
'**********************************************
33
' ę件å: NetRube_Upload.asp
34
' ēę¬: NetRube Upload Class Version 2.1 Build 20050228
35
' ä½č
: NetRube(ē½ē»ä¹”巓佬)
36
' ēµåé®ä»¶: NetRube@126.com
37
' ę„ę: 2005幓02ę28ę„
38
' 声ę: ę件äøä¼ ē±»
39
' ę¬äøä¼ ē±»åÆ仄čŖē±ä½æēØļ¼ä½čÆ·äæēę¤ēę声ęäæ”ęÆ
40
' å¦ęęØåƹę¬äøä¼ ē±»čæč”äæ®ę¹å¢å¼ŗļ¼
41
' čÆ·åéäø份ē»äæŗć
42
'**********************************************
48
Private nMaxSize, nErr, sAllowed, sDenied
50
Private Sub Class_Initialize
54
Set File = Server.CreateObject("Scripting.Dictionary")
56
Set Form = Server.CreateObject("Scripting.Dictionary")
59
Set oSourceData = Server.CreateObject("ADODB.Stream")
65
Private Sub Class_Terminate
72
Set oSourceData = Nothing
75
Public Property Get Version
76
Version = "NetRube Upload Class Version 1.0 Build 20041218"
79
Public Property Get ErrNum
83
Public Property Let MaxSize(nSize)
87
Public Property Let Allowed(sExt)
91
Public Property Let Denied(sExt)
97
aCType = Split(Request.ServerVariables("HTTP_CONTENT_TYPE"), ";")
98
If aCType(0) <> "multipart/form-data" Then
104
nTotalSize = Request.TotalBytes
105
If nTotalSize < 1 Then
109
If nMaxSize > 0 And nTotalSize > nMaxSize Then
114
oSourceData.Write Request.BinaryRead(nTotalSize)
115
oSourceData.Position = 0
117
Dim oTotalData, oFormStream, sFormHeader, sFormName, bCrLf, nBoundLen, nFormStart, nFormEnd, nPosStart, nPosEnd, sBoundary
119
oTotalData = oSourceData.Read
120
bCrLf = ChrB(13) & ChrB(10)
121
sBoundary = MidB(oTotalData, 1, InStrB(1, oTotalData, bCrLf) - 1)
122
nBoundLen = LenB(sBoundary) + 2
123
nFormStart = nBoundLen
125
Set oFormStream = Server.CreateObject("ADODB.Stream")
127
Do While (nFormStart + 2) < nTotalSize
128
nFormEnd = InStrB(nFormStart, oTotalData, bCrLf & bCrLf) + 3
134
oSourceData.Position = nFormStart
135
oSourceData.CopyTo oFormStream, nFormEnd - nFormStart
139
sFormHeader = .ReadText
143
nFormStart = InStrB(nFormEnd, oTotalData, sBoundary) - 1
144
nPosStart = InStr(22, sFormHeader, " name=", 1) + 7
145
nPosEnd = InStr(nPosStart, sFormHeader, """")
146
sFormName = Mid(sFormHeader, nPosStart, nPosEnd - nPosStart)
148
If InStr(45, sFormHeader, " filename=", 1) > 0 Then
149
Set File(sFormName) = New NetRube_FileInfo
150
File(sFormName).FormName = sFormName
151
File(sFormName).Start = nFormEnd
152
File(sFormName).Size = nFormStart - nFormEnd - 2
153
nPosStart = InStr(nPosEnd, sFormHeader, " filename=", 1) + 11
154
nPosEnd = InStr(nPosStart, sFormHeader, """")
155
File(sFormName).ClientPath = Mid(sFormHeader, nPosStart, nPosEnd - nPosStart)
156
File(sFormName).Name = Mid(File(sFormName).ClientPath, InStrRev(File(sFormName).ClientPath, "\") + 1)
157
File(sFormName).Ext = LCase(Mid(File(sFormName).Name, InStrRev(File(sFormName).Name, ".") + 1))
158
nPosStart = InStr(nPosEnd, sFormHeader, "Content-Type: ", 1) + 14
159
nPosEnd = InStr(nPosStart, sFormHeader, vbCr)
160
File(sFormName).MIME = Mid(sFormHeader, nPosStart, nPosEnd - nPosStart)
166
oSourceData.Position = nPosEnd
167
oSourceData.CopyTo oFormStream, nFormStart - nFormEnd - 2
171
Form(sFormName) = .ReadText
176
nFormStart = nFormStart + nBoundLen
180
Set oFormStream = Nothing
183
Public Sub SaveAs(sItem, sFileName)
184
If File(sItem).Size < 1 Then
189
If Not IsAllowed(File(sItem).Ext) Then
195
Set oFileStream = Server.CreateObject("ADODB.Stream")
200
oSourceData.Position = File(sItem).Start
201
oSourceData.CopyTo oFileStream, File(sItem).Size
203
.SaveToFile sFileName, 2
206
Set oFileStream = Nothing
209
Private Function IsAllowed(sExt)
212
oRE.IgnoreCase = True
216
oRE.Pattern = sAllowed
217
IsAllowed = (sAllowed = "") Or oRE.Test(sExt)
219
oRE.Pattern = sDenied
220
IsAllowed = Not oRE.Test(sExt)
227
Class NetRube_FileInfo
228
Dim FormName, ClientPath, Path, Name, Ext, Content, Size, MIME, Start
b'\\ No newline at end of file'