+++ /dev/null
-<!--\r
- * FCKeditor - The text editor for internet\r
- * Copyright (C) 2003-2006 Frederico Caldeira Knabben\r
- * \r
- * Licensed under the terms of the GNU Lesser General Public License:\r
- * http://www.opensource.org/licenses/lgpl-license.php\r
- * \r
- * For further information visit:\r
- * http://www.fckeditor.net/\r
- * \r
- * "Support Open Source software. What about a donation today?"\r
- * \r
- * File Name: class_upload.asp\r
- * These are the classes used to handle ASP upload without using third\r
- * part components (OCX/DLL).\r
- * \r
- * File Authors:\r
- * NetRube (netrube@126.com)\r
--->\r
-<%\r
-'**********************************************\r
-' File: NetRube_Upload.asp\r
-' Version: NetRube Upload Class Version 2.1 Build 20050228\r
-' Author: NetRube\r
-' Email: NetRube@126.com\r
-' Date: 02/28/2005\r
-' Comments: The code for the Upload.\r
-' This can free usage, but please\r
-' not to delete this copyright information.\r
-' If you have a modification version,\r
-' Please send out a duplicate to me.\r
-'**********************************************\r
-' 文件名: NetRube_Upload.asp\r
-' 版本: NetRube Upload Class Version 2.1 Build 20050228\r
-' 作者: NetRube(网络乡巴佬)\r
-' 电子邮件: NetRube@126.com\r
-' 日期: 2005年02月28日\r
-' 声明: 文件上传类\r
-' 本上传类可以自由使用,但请保留此版权声明信息\r
-' 如果您对本上传类进行修改增强,\r
-' 请发送一份给俺。\r
-'**********************************************\r
-\r
-Class NetRube_Upload\r
-\r
- Public File, Form\r
- Private oSourceData\r
- Private nMaxSize, nErr, sAllowed, sDenied\r
- \r
- Private Sub Class_Initialize\r
- nErr = 0\r
- nMaxSize = 1048576\r
- \r
- Set File = Server.CreateObject("Scripting.Dictionary")\r
- File.CompareMode = 1\r
- Set Form = Server.CreateObject("Scripting.Dictionary")\r
- Form.CompareMode = 1\r
- \r
- Set oSourceData = Server.CreateObject("ADODB.Stream")\r
- oSourceData.Type = 1\r
- oSourceData.Mode = 3\r
- oSourceData.Open\r
- End Sub\r
- \r
- Private Sub Class_Terminate\r
- Form.RemoveAll\r
- Set Form = Nothing\r
- File.RemoveAll\r
- Set File = Nothing\r
- \r
- oSourceData.Close\r
- Set oSourceData = Nothing\r
- End Sub\r
- \r
- Public Property Get Version\r
- Version = "NetRube Upload Class Version 1.0 Build 20041218"\r
- End Property\r
-\r
- Public Property Get ErrNum\r
- ErrNum = nErr\r
- End Property\r
- \r
- Public Property Let MaxSize(nSize)\r
- nMaxSize = nSize\r
- End Property\r
- \r
- Public Property Let Allowed(sExt)\r
- sAllowed = sExt\r
- End Property\r
- \r
- Public Property Let Denied(sExt)\r
- sDenied = sExt\r
- End Property\r
-\r
- Public Sub GetData\r
- Dim aCType\r
- aCType = Split(Request.ServerVariables("HTTP_CONTENT_TYPE"), ";")\r
- If aCType(0) <> "multipart/form-data" Then\r
- nErr = 1\r
- Exit Sub\r
- End If\r
- \r
- Dim nTotalSize\r
- nTotalSize = Request.TotalBytes\r
- If nTotalSize < 1 Then\r
- nErr = 2\r
- Exit Sub\r
- End If\r
- If nMaxSize > 0 And nTotalSize > nMaxSize Then\r
- nErr = 3\r
- Exit Sub\r
- End If\r
- \r
- oSourceData.Write Request.BinaryRead(nTotalSize)\r
- oSourceData.Position = 0\r
- \r
- Dim oTotalData, oFormStream, sFormHeader, sFormName, bCrLf, nBoundLen, nFormStart, nFormEnd, nPosStart, nPosEnd, sBoundary\r
- \r
- oTotalData = oSourceData.Read\r
- bCrLf = ChrB(13) & ChrB(10)\r
- sBoundary = MidB(oTotalData, 1, InStrB(1, oTotalData, bCrLf) - 1)\r
- nBoundLen = LenB(sBoundary) + 2\r
- nFormStart = nBoundLen\r
- \r
- Set oFormStream = Server.CreateObject("ADODB.Stream")\r
- \r
- Do While (nFormStart + 2) < nTotalSize\r
- nFormEnd = InStrB(nFormStart, oTotalData, bCrLf & bCrLf) + 3\r
- \r
- With oFormStream\r
- .Type = 1\r
- .Mode = 3\r
- .Open\r
- oSourceData.Position = nFormStart\r
- oSourceData.CopyTo oFormStream, nFormEnd - nFormStart\r
- .Position = 0\r
- .Type = 2\r
- .CharSet = "UTF-8"\r
- sFormHeader = .ReadText\r
- .Close\r
- End With\r
- \r
- nFormStart = InStrB(nFormEnd, oTotalData, sBoundary) - 1\r
- nPosStart = InStr(22, sFormHeader, " name=", 1) + 7\r
- nPosEnd = InStr(nPosStart, sFormHeader, """")\r
- sFormName = Mid(sFormHeader, nPosStart, nPosEnd - nPosStart)\r
- \r
- If InStr(45, sFormHeader, " filename=", 1) > 0 Then\r
- Set File(sFormName) = New NetRube_FileInfo\r
- File(sFormName).FormName = sFormName\r
- File(sFormName).Start = nFormEnd\r
- File(sFormName).Size = nFormStart - nFormEnd - 2\r
- nPosStart = InStr(nPosEnd, sFormHeader, " filename=", 1) + 11\r
- nPosEnd = InStr(nPosStart, sFormHeader, """")\r
- File(sFormName).ClientPath = Mid(sFormHeader, nPosStart, nPosEnd - nPosStart)\r
- File(sFormName).Name = Mid(File(sFormName).ClientPath, InStrRev(File(sFormName).ClientPath, "\") + 1)\r
- File(sFormName).Ext = LCase(Mid(File(sFormName).Name, InStrRev(File(sFormName).Name, ".") + 1))\r
- nPosStart = InStr(nPosEnd, sFormHeader, "Content-Type: ", 1) + 14\r
- nPosEnd = InStr(nPosStart, sFormHeader, vbCr)\r
- File(sFormName).MIME = Mid(sFormHeader, nPosStart, nPosEnd - nPosStart)\r
- Else\r
- With oFormStream\r
- .Type = 1\r
- .Mode = 3\r
- .Open\r
- oSourceData.Position = nPosEnd\r
- oSourceData.CopyTo oFormStream, nFormStart - nFormEnd - 2\r
- .Position = 0\r
- .Type = 2\r
- .CharSet = "UTF-8"\r
- Form(sFormName) = .ReadText\r
- .Close\r
- End With\r
- End If\r
- \r
- nFormStart = nFormStart + nBoundLen\r
- Loop\r
- \r
- oTotalData = ""\r
- Set oFormStream = Nothing\r
- End Sub\r
-\r
- Public Sub SaveAs(sItem, sFileName)\r
- If File(sItem).Size < 1 Then\r
- nErr = 2\r
- Exit Sub\r
- End If\r
- \r
- If Not IsAllowed(File(sItem).Ext) Then\r
- nErr = 4\r
- Exit Sub\r
- End If\r
- \r
- Dim oFileStream\r
- Set oFileStream = Server.CreateObject("ADODB.Stream")\r
- With oFileStream\r
- .Type = 1\r
- .Mode = 3\r
- .Open\r
- oSourceData.Position = File(sItem).Start\r
- oSourceData.CopyTo oFileStream, File(sItem).Size\r
- .Position = 0\r
- .SaveToFile sFileName, 2\r
- .Close\r
- End With\r
- Set oFileStream = Nothing\r
- End Sub\r
- \r
- Private Function IsAllowed(sExt)\r
- Dim oRE\r
- Set oRE = New RegExp\r
- oRE.IgnoreCase = True\r
- oRE.Global = True\r
- \r
- If sDenied = "" Then\r
- oRE.Pattern = sAllowed\r
- IsAllowed = (sAllowed = "") Or oRE.Test(sExt)\r
- Else\r
- oRE.Pattern = sDenied\r
- IsAllowed = Not oRE.Test(sExt)\r
- End If\r
- \r
- Set oRE = Nothing\r
- End Function\r
-End Class\r
-\r
-Class NetRube_FileInfo\r
- Dim FormName, ClientPath, Path, Name, Ext, Content, Size, MIME, Start\r
-End Class\r
-%>
\ No newline at end of file