upload.asp
上传用户:zhenfu
上传日期:2020-04-09
资源大小:137k
文件大小:2k
源码类别:

加密解密

开发平台:

CHM

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
  2. <%
  3. on error resume next
  4. Server.ScriptTimeOut=5000
  5. %>
  6. <!--#include file="UpLoadClass.asp"-->
  7. <%
  8. if Request.QueryString("action")="upload" then
  9. dim MyRequest,lngUpSize,SavePath
  10. SavePath="../uploadfile/" '设置上传目录(可以是相对路径)
  11. SavePath=replace(SavePath,"","/")
  12. Set MyRequest=new UpLoadClass
  13. MyRequest.SavePath=SavePath
  14. '设置允许上传的文件类型
  15. UploadType=trim(Request.QueryString("uploadtype"))
  16. if UploadType="img" then
  17. MyRequest.FileType="jpg/gif/bmp/png"
  18. elseif UploadType="attach" then
  19. MyRequest.FileType="rar/zip"
  20. end if
  21. '判断上传目录是否存在,不存在则自动创建
  22. FolderPath=server.MapPath(SavePath)
  23. Set FSO=Server.CreateObject("Scripting.FileSystemObject")
  24. if FSO.FolderExists(FolderPath)=false then
  25. FSO.CreateFolder(FolderPath)
  26. end if
  27. Set FSO=nothing
  28. '取得当前文件所在目录
  29. FileName=Right(Request.Servervariables("Script_Name"),len(Request.Servervariables("Script_Name"))-InstrRev(Request.Servervariables("Script_Name"),"/"))
  30. FileFolder=replace(Request.Servervariables("Script_Name"),FileName,"")
  31. '获取文件地址的根绝对路径
  32. if left(SavePath,1)="/" then
  33. uploadPath=SavePath
  34. else
  35. uploadPath=FileFolder&SavePath
  36. end if
  37. lngUpSize = MyRequest.Open()
  38.   select case MyRequest.error
  39.          case 0
  40.  if UploadType="img" then
  41.   response.Write("<script>window.parent.LoadIMG('"&uploadPath&trim(MyRequest.form("file1"))&"');</script>")
  42.  elseif UploadType="attach" then
  43.   response.Write("<script>window.parent.LoadAttach('"&uploadPath&trim(MyRequest.form("file1"))&"');</script>")
  44.  end if
  45.          case 1
  46.  response.Write("<script>alert('文件过大!');window.parent.$('divProcessing').style.display='none';history.back();</script>")
  47.  case 2
  48.  response.Write("<script>alert('不允许上传该类型的文件!');window.parent.$('divProcessing').style.display='none';history.back();</script>")
  49.          case 3
  50.  response.Write("<script>alert('不允许上传该类型的文件!');window.parent.$('divProcessing').style.display='none';history.back();</script>")
  51.  case else
  52.  response.Write("<script>alert('文件上传出错!');window.parent.$('divProcessing').style.display='none';history.back();</script>")
  53.   end select
  54. end if
  55. %>