目录结构:
AdminSystem 管理后台
eWebEditor
UploadFile 这个是存放上传文件
disp.asp 为显示文件。
大家帮忙看下它的上传代码:
初始化上传限制数据
Sub InitUpload()
sType = UCase(Trim(Request.QueryString("type")))
sStyleName = Get_SafeStr(Trim(Request.QueryString("style")))
sSql = "select * from ewebeditor_style where s_name=" & sStyleName & ""
oRs.Open sSql, oConn, 0, 1
If Not oRs.Eof Then
sBaseUrl = oRs("S_BaseUrl")
nUploadObject = oRs("S_UploadObject")
nAutoDir = oRs("S_AutoDir")
sUploadDir = oRs("S_UploadDir")
sUploadDir = "../"&sUploadDir
Select Case sBaseUrl
Case "0"
sContentPath = oRs("S_ContentPath")
Case "1"
sContentPath = RelativePath2RootPath(sUploadDir)
sContentPath = sUploadDir
Case "2"
sContentPath = RootPath2DomainPath(RelativePath2RootPath(sUploadDir))
End Select
Select Case sType
Case "REMOTE"
sAllowExt = oRs("S_RemoteExt")
nAllowSize = oRs("S_RemoteSize")
Case "FILE"
sAllowExt = oRs("S_FileExt")
nAllowSize = oRs("S_FileSize")
Case "MEDIA"
sAllowExt = oRs("S_MediaExt")
nAllowSize = oRs("S_MediaSize")
Case "FLASH"
sAllowExt = oRs("S_FlashExt")
nAllowSize = oRs("S_FlashSize")
Case Else
sAllowExt = oRs("S_ImageExt")
nAllowSize = oRs("S_ImageSize")
End Select
Else
OutScript("parent.UploadError(无效的样式ID号,请通过页面上的链接进行操作!)")
End If
oRs.Close
任何情况下都不允许上传asp脚本文件
sAllowExt = Replace(UCase(sAllowExt), "ASP", "")
End Sub
转为根路径格式
Function RelativePath2RootPath(url)
Dim sTempUrl
sTempUrl = url
If Left(sTempUrl, 1) = "/" Then
RelativePath2RootPath = sTempUrl
Exit Function
End If
Dim sWebEditorPath
sWebEditorPath = Request.ServerVariables("SCRIPT_NAME")
sWebEditorPath = Left(sWebEditorPath, InstrRev(sWebEditorPath, "/") - 1)
Do While Left(sTempUrl, 3) = "../"
sTempUrl = Mid(sTempUrl, 4)
sWebEditorPath = Left(sWebEditorPath, InstrRev(sWebEditorPath, "/") - 1)
Loop
RelativePath2RootPath = sWebEditorPath & "/" & sTempUrl
End Function
对函数RelativePath2RootPath 怎样改动使上传文件上传到UploadFile 中
Function RelativePath2RootPath(url)
RelativePath2RootPath = Server.MapPath("UploadFile") & "\"
End Function