⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 viewfile.asp

📁 YxBBs是由Y网出品的一套ASP论坛系统,拥有小巧、高速、简捷、易用等特点。在YxBBs1.X刚起步的时候经过了大量的版本测试,现在YxBBs完善了技术
💻 ASP
字号:
<%if Request("action")="" then%>
<%
Const FilePath = "UploadFile/TopicFile"
Const FacePath = "UploadFile/Head"

On Error Resume Next
Response.Buffer = True
Response.Clear

If LCase(Request("Path"))="face" Then
        TFilePath=  FacePath & "/" & Request("FileName")
	Else
       TFilePath = FilePath & "/" & Request("FileName")
	End If

Function UseStream(FileName)
Dim FileStream,File
Set FileStream = Server.CreateObject("ADODB.Stream")
FileStream.Open
FileStream.Type = 1
File = server.MapPath(FileName)
FileStream.LoadFromFile(File)
'Response.ContentType = "application/octet-stream"

Response.BinaryWrite FileStream.Read 
Response.Flush

FileStream.Close
Set FileStream = Nothing
End Function



Function DownloadFile(FileName)
    On error resume next
	Server.ScriptTimeOut=999999
	Response.Clear
    Dim FileType,ADS,StrFileName,Data
    FileType=Lcase(Split(FileName,".")(ubound(Split(FileName,"."))))
	StrFileName=Server.Mappath(FileName)
	TempFileName = Split(StrFileName,"\")(Ubound(Split(StrFileName,"\")))
    Set ADS = Server.CreateObject("ADODB.Stream") 
	ADS.Open
	ADS.Type = 1 
    ADS.LoadFromFile(StrFileName)
	Data=ADS.Read
	Fsize=Clng(lenb(Data))
	If Err Then
  	   Response.Redirect("Images/NoImg.gif")
	   'Response.Write("<h1>错误: </h1>" & err.Description & "<p>")
       Response.End 
    End If
	ADS.Close
    If Response.IsClientConnected Then 
       If FileType="gif" Or FileType="jpg" Or FileType="jpeg" Or FileType="bmp" Then 
	      Response.ContentType = "image/*"
	   Else
	      Response.AddHeader "Content-Disposition", "attachment; filename=" & TempFileName
		  Response.ContentType = "application/ms-download"
	   End If
	   Response.AddHeader "Content-Length", Fsize
 	   Response.CharSet = "UTF-8" 
	   Response.ContentType = "application/octet-stream" 
	   Response.BinaryWrite Data
	   Response.Flush
	End If
End Function

Dim Server_v1,Server_v2
Server_v1=Cstr(Request.ServerVariables("HTTP_REFERER"))
Server_v2=Cstr(Request.ServerVariables("SERVER_NAME"))
If Server_v1<>"" And Mid(Server_v1,8,Len(Server_v2)) <> Server_v2 Then
     TFilePath = "Images/NoImg1.gif"
End If




If ChkFile(TFilePath) Then Response.Redirect("Images/NoImg.gif")
DownloadFile(TFilePath)
Function ChkFile(FileName)
Dim Temp,FileType
   ChkFile=False
   FileType=Lcase(Split(FileName,".")(ubound(Split(FileName,"."))))
   Temp="|asp|aspx|cgi|php|cdx|cer|asa|"
   If Instr(Temp,"|"&FileType&"|")>0 Then  ChkFile=True
End Function
end if%>
<%if Request("action")="Upload" then%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
BODY {
	FONT-SIZE: 12px;
	FONT-FAMILY: "宋体","Verdana", "Arial", "Helvetica", "sans-serif";
	margin-left: 0px;
}
Input {
	font-family: Arial;
	font-size: 12px;
	font-style: normal;
	line-height: normal;
	font-weight: normal;
	font-variant: normal;
	background-color: #F6F6F6;
	height: 18px;
	border-top-width: 1px;
	border-right-width: 1px;
	border-bottom-width: 1px;
	border-left-width: 1px;
	border-top-style: solid;
	border-right-style: solid;
	border-bottom-style: solid;
	border-left-style: solid;
	border-top-color: #999999;
	border-right-color: #EEEEEE;
	border-bottom-color: #EEEEEE;
	border-left-color: #999999;
}
</style>
</head>
<%
Dim Flag
BoardID=Request.QueryString("BoardID")
If Request("Flag") = "" Then  Flag= 0 Else Flag = 1
Response.Write"<body topmargin='0' leftmargin='0'><form action='SaveUpload.Asp?BoardID="&BoardID&"&Flag="&Flag&"' method='post' enctype='multipart/form-data' target='_self'><input name='filedata' type='file' size='18'> <input type='Submit' value='上 传' name='Submit' id='Submit'></form>"
%>
</body>
</html>
<%end if%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -