?? demo.asp
字號:
<%@Language=VBScript%>
<%
Option Explicit
Response.Buffer = True
'-----------------------------------------------------------------------
'--- DvFile-Up ASP 上傳組件 示范文件
'--- Copyright (c) 2004 Aspsky, Inc.
'--- Mail: fssunwin@aspsky.net http://www.aspsky.net
'-----------------------------------------------------------------------
%>
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<TITLE>DvFile-Up ASP 上傳組件 示范文件</TITLE>
</HEAD>
<BODY bgcolor="#FFCCFF">
<%
Dim FormPath
FormPath = "TempUpload/" ''定義上傳路徑
Upload_0
Sub Upload_0()
Dim Upload
Dim File,FormName,FileName,FileExt,SaveFile
Dim CountSize,UseTime
CountSize = 0
Set Upload = Server.CreateObject("DvFile.Upload") ''建立上傳對象
Upload.InceptFileType = "jpg,gif,png,bmp,jpeg" ''上傳文件類型限制 以 “,” 號分隔
Upload.MaxSize = -1 ''限制大小 :-1為無限,單位 B
Upload.Install
''加載上傳數據
If Upload.Err > 0 Then ''錯誤參數
''輸出錯誤信息
Select Case Upload.Err
Case 1 : Response.Write Upload.Description ''請先選擇你要上傳的文件
Case 2 : Response.Write Upload.Description ''文件大小超過了限制 "&Upload.MaxSize/1024&"K
Case 3 : Response.Write Upload.Description ''非法的上傳類型
Case 4 : Response.Write Upload.Description ''所上傳的類型受系統限制
Case 5 : Response.Write Upload.Description ''參數有誤,上傳意外中止
End Select
Response.Write " [ <a href=# onclick=history.go(-1)>重新上傳</a> ]"
Exit Sub
Else
'If Upload.Count>1 Then Response.Write "上傳個數超過限制" : Exit Sub
'FormPath = Upload.Form("filepath") ''從表單filepath獲取上傳路徑
For Each FormName In Upload.File ''列出所有上傳了的文件
Set File = Upload.File(FormName) ''生成一個文件對象
FileExt = File.FileExt ''獲取上傳文件后綴名
FormPath = FormatPath(FormPath) ''格式化上傳路徑
FileName = FormatName(FileExt) ''定義文件名
SaveFile = FormPath & FileName
If File.FileSize>0 Then ''如果 FileSize > 0 說明有文件數據
Upload.SaveToFile Server.Mappath(SaveFile),FormName ''保存文件
'Upload.FileData(FormName) ''獲取單個文件內容數據
''輸出信息:
Response.Write "原文件名:" & File.FileName
Response.Write "<BR>"
Response.Write "文件表單名:" & File.FormName
Response.Write "<BR>"
Response.Write "文件來源路徑:" & File.FilePath
Response.Write "<BR>"
Response.Write "文件名:" & FileName
Response.Write "<BR>"
Response.Write "文件類型(File.FileType):" & File.FileType
Response.Write "<BR>"
Response.Write "文件后綴(File.FileExt):" & File.FileExt
Response.Write "<BR>"
Response.Write "圖像寬(File.FileWidth):" & File.FileWidth
Response.Write "<BR>"
Response.Write "圖像高(File.FileHeight):" & File.FileHeight
Response.Write "<BR>"
Response.Write "文件大?。‵ile.FileSize):" & File.FileSize
Response.Write "<BR>"
Response.Write "保存路徑:" & SaveFile
Response.Write "<BR>"
Response.Write "圖片上傳成功!<p>"
End If
Set File=Nothing
Next
Response.Write "共上傳"& Upload.Count &"個文件 ;By "& Upload.Version &"<p>"
End If
UseTime = Upload.UseTime '總消耗時間
CountSize = Upload.TotalBytes '上傳總字節數
Response.Write "總執行時間:"& UseTime &"亳秒"
Set Upload=Nothing
End Sub
Function FormatPath(Path)
FormatPath = Replace(Path,Chr(0),"")
End Function
Function FormatName(FileExt)
Dim RanNum
Randomize
RanNum = Int(90000*rnd)+10000
FormatName = Year(now)&Month(now)&Day(now)&Hour(now)&Minute(now)&Second(now)&RanNum&"."&FileExt
End Function
%>
</BODY>
</HTML>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -