?? upload.asp
字號:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
'----------------------------------------------------------
'***************** 風聲無組件上傳類 2.1 *****************
'速度測試
'本程序將保存您上傳的文件,并記錄上傳速度及相關信息<br />
'上傳速度主要由網速決定,測試結果僅供參考<br />
'該例以 gb2312(類默認,無須顯示設置)字符集測試
'下面是上傳程序(upload.asp)的代碼和注釋
'**********************************************************
'----------------------------------------------------------
OPTION EXPLICIT
Server.ScriptTimeOut=5000
%>
<!--#include file="conn.asp"-->
<!--#include file="../UpLoadClass.asp"-->
<!--#include file="../help/Code2Info.sc.asp"-->
<%
dim nTime : nTime = Timer()
dim myrequest,lngUpSize
Set myrequest=new UpLoadClass
myrequest.MaxSize = 5000*1024
myrequest.FileType = "rar/zip/gif/jpg/swf"
myrequest.Savepath = "UpLoadFile/"
lngUpSize = myrequest.Open()
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>速度測試——風聲無組件上傳類</title>
<link href="../style/default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="Context">
<%
Response.Write("<p>程序版本:"&myrequest.Version&"</p>")
Response.Write("<p id=""Title"">字 符 集:"&myrequest.Charset&"</p>")
dim strFile1 : strFile1=myrequest.Form("Photo")
dim intError : intError=myrequest.Form("photo_Err")
dim lngSize1 : lngSize1=0
Response.Write("<p><strong>上傳文件 1 信息</strong>")
if intError>=0 then
Response.Write "<br />文件名:<a href='"&myrequest.Savepath&strFile1&"' target='_blank'>"&strFile1&"</a>"
Response.Write "<br />類 型:"&myrequest.Form("Photo_Type")
Response.Write "<br />源文件:"&myrequest.Form("Photo_Name")
Response.Write "<br />寬×高:"&myrequest.Form("photo_Width")&"×"&myrequest.Form("photo_Height")
lngSize1=myrequest.Form("photo_Size")
if intError>0 then strFile1="Err:"&intError&"/"&myrequest.Form("photo_Name")
Response.Write "<br />大 ?。?quot;&lngSize1&" Bytes"
Response.Write "<br />源路徑:"&myrequest.Form("photo_Path")
Response.Write "<br />擴展名:"&myrequest.Form("photo_Ext")
end if
Response.Write "<br />"&Err2Info(myrequest.Form("photo_Err"))
Response.Write("</p>")
dim strFile2 : strFile2=myrequest.Form("Photo2")
intError=myrequest.Form("photo2_Err")
dim lngSize2 : lngSize2=0
Response.Write("<p><strong>上傳文件 2 信息</strong>")
if intError>=0 then
Response.Write "<br />文件名:<a href='"&myrequest.Savepath&strFile2&"' target='_blank'>"&strFile2&"</a>"
Response.Write "<br />類 型:"&myrequest.Form("Photo2_Type")
Response.Write "<br />源文件:"&myrequest.Form("Photo2_Name")
Response.Write "<br />寬×高:"&myrequest.Form("photo2_Width")&"×"&myrequest.Form("photo2_Height")
lngSize2=myrequest.Form("photo2_Size")
if intError>0 then strFile2="Err:"&intError&"/"&myrequest.Form("photo2_Name")
Response.Write "<br />大 小:"&lngSize2&" Bytes"
Response.Write "<br />源路徑:"&myrequest.Form("photo2_Path")
Response.Write "<br />擴展名:"&myrequest.Form("photo2_Ext")
end if
Response.Write "<br />"&Err2Info(myrequest.Form("photo2_Err"))
Response.Write("</p>")
dim strUser : strUser=replace(replace(left(myrequest.Form("intro"),8),"<","["),">","]")
Response.Write "<p>網友大名:"&strUser&"</p>"
dim strMessage : strMessage=replace(replace(left(myrequest.Form("intro2"),30),"<","["),">","]")
Response.Write "<p>網友留言:"&strMessage&"</p>"
Response.Write "<p>"&Error2Info(myrequest.Error)&"</p>"
Set myrequest=nothing
nTime = Timer()-nTime
dim dblTime : dblTime=FormatNumber(nTime,3)
Response.Write "<p>上傳用時:"&dblTime&" s</p>"
Response.Write("<p><a href='uplist.asp'>[查看上傳歷史紀錄]</a></p>")
' 上傳處理完成
' 開始數據庫處理
dim lngFileSize : lngFileSize = lngSize1+lngSize2
if lngFileSize>0 then
Response.Write "<p>平均上傳速率:"
dim dblSpeed : dblSpeed = -1
if nTime>0 then dblSpeed=FormatNumber(lngFileSize/(1024*nTime),3)
'這里用lngUpSize更合理,lngUpSize由Open返回
'if nTime>0 then dblSpeed=FormatNumber(lngUpSize/(1024*nTime),3)
Response.Write dblSpeed&" k/s</p>"
if strUser ="" then strUser="匿名"
if strMessage="" then strMessage=" "
if strFile1 ="" then strFile1=" "
if strFile2 ="" then strFile2=" "
dim strIp : strIp=GetIp()
dim sql,conn
set conn=Server.CreateObject("ADODB.Connection")
conn.Open strDconn
sql="Insert Into book"&_
"(datePost,strUser,strMessage,strFile1,strSize1,strFile2,strSize2,strTime,strSpeed,strIp) "&_
"values"&_
"(#"&Now()&"#,'"&strUser&"','"&strMessage&"','"&strFile1&"',"&lngSize1&",'"&strFile2&"',"&lngSize2&","&dblTime&","&dblSpeed&",'"&strIp&"')"
conn.Execute(sql)
conn.Close()
set conn=nothing
end if
%>
</div>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -