?? index.htm
字號:
<table border="0" cellspacing="0" cellpadding="0" class=Table2 align="center">
<tr>
<td>
<table border="0" width="95%" height="1" bgcolor="#000000" cellspacing="1" cellpadding="2" align="center">
<tr>
<td width="100%" CLASS=CODEBODY1>
<img border="0" src="img/component.gif" align="baseline">
<span class="title">組件ProgId:DvFile.Upload</span></td>
</tr>
<tr>
<td CLASS=CODEBODY2>說明:程序ID。用于創建應用程序對象范例</td>
</tr>
<tr>
<td CLASS=CODEBODY2 valign="top">
范例:<DIV class="code">Set Upload = Server.CreateObject("DvFile.Upload")</DIV>
</td>
</tr>
</table>
<table border="0" width="95%" height="1" bgcolor="#000000" cellspacing="1" cellpadding="2" align="center">
<tr>
<td width="100%" CLASS=CODEBODY1>
<img border="0" src="img/component.gif" align="baseline">
<span class="title">.InceptFileType</span></td>
</tr>
<tr>
<td CLASS=CODEBODY2>說明:設置上傳文件類型限制,以 “,” 號分隔;沒有返回值 </td>
</tr>
<tr>
<td CLASS=CODEBODY2 valign="top">
范例:只允許上傳jpg,gif,png,bmp,jpeg等格式的文件。<DIV class="code">Upload.InceptFileType = "jpg,gif,png,bmp,jpeg"</DIV>
</td>
</tr>
</table>
<table border="0" width="95%" height="1" bgcolor="#000000" cellspacing="1" cellpadding="2" align="center">
<tr>
<td width="100%" CLASS=CODEBODY1>
<img border="0" src="img/component.gif" align="baseline">
<span class="title">.MaxSize</span></td>
</tr>
<tr>
<td CLASS=CODEBODY2>說明:設置上傳文件限制大小 :-1為無限,單位 為字節,沒有返回值 </td>
</tr>
<tr>
<td CLASS=CODEBODY2 valign="top">
范例:上限限制為100KB<DIV class="code">Upload.MaxSize = 102400</DIV>
</td>
</tr>
</table>
<table border="0" width="95%" height="1" bgcolor="#000000" cellspacing="1" cellpadding="2" align="center">
<tr>
<td width="100%" CLASS=CODEBODY1>
<img border="0" src="img/component.gif" align="baseline">
<span class="title">.Install</span></td>
</tr>
<tr>
<td CLASS=CODEBODY2>說明:執行加載并分析上傳數據過程</td>
</tr>
<tr>
<td CLASS=CODEBODY2 valign="top">
范例:<DIV class="code">Upload.Install</DIV>
</td>
</tr>
</table>
<table border="0" width="95%" height="1" bgcolor="#000000" cellspacing="1" cellpadding="2" align="center">
<tr>
<td width="100%" CLASS=CODEBODY1>
<img border="0" src="img/component.gif" align="baseline">
<span class="title">.SaveToFile PATH,FormName</span></td>
</tr>
<tr>
<td CLASS=CODEBODY2>說明:執行保存上傳文件至服務器;PATH :保存到服務器的物理路徑,FormName 為文件表單個數</td>
</tr>
<tr>
<td CLASS=CODEBODY2 valign="top">
范例:如上傳1個文件,保存至D:\TempFile\目錄下,文件名為123.gif<DIV class="code">Upload.SaveToFile "D:\TempFile\123.gif",1</DIV>
</td>
</tr>
</table>
<table border="0" width="95%" height="1" bgcolor="#000000" cellspacing="1" cellpadding="2" align="center">
<tr>
<td width="100%" CLASS=CODEBODY1>
<img border="0" src="img/component.gif" align="baseline">
<span class="title">.Count</span></td>
</tr>
<tr>
<td CLASS=CODEBODY2>說明:返還上傳文件總數,類型為數字型</td>
</tr>
<tr>
<td CLASS=CODEBODY2 valign="top">
范例:<DIV class="code">共上傳"& Upload.Count &"個文件</DIV>
</td>
</tr>
</table>
<table border="0" width="95%" height="1" bgcolor="#000000" cellspacing="1" cellpadding="2" align="center">
<tr>
<td width="100%" CLASS=CODEBODY1>
<img border="0" src="img/component.gif" align="baseline">
<span class="title">.TotalBytes</span></td>
</tr>
<tr>
<td CLASS=CODEBODY2>說明:返還上傳文件大小總字節數,類型為數字型</td>
</tr>
<tr>
<td CLASS=CODEBODY2 valign="top">
范例:<DIV class="code">共上傳"& Upload.TotalBytes &"字節</DIV>
</td>
</tr>
</table>
<table border="0" width="95%" height="1" bgcolor="#000000" cellspacing="1" cellpadding="2" align="center">
<tr>
<td width="100%" CLASS=CODEBODY1>
<img border="0" src="img/component.gif" align="baseline">
<span class="title">.UseTime</span></td>
</tr>
<tr>
<td CLASS=CODEBODY2>說明:返還上傳文件總消耗時間,類型為數字型</td>
</tr>
<tr>
<td CLASS=CODEBODY2 valign="top">
范例:<DIV class="code">總執行時間:"& Upload.UseTime &" 亳秒</DIV>
</td>
</tr>
</table>
</td>
</tr>
<tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" class=Table2 align="center">
<tr>
<td width="1" height="1" valign="top"><img border="0" src="img/td_05.gif"></td>
<td height="1" background="img/td_06.gif" width="*"><img border="0" src="img/td_06.gif"></td>
<td width="1" height="1" valign="top"><img border="0" src="img/td_07.gif"></td>
</tr>
</table>
<br>
<table border="0" cellspacing="0" cellpadding="0" class=Table2 align="center">
<tr>
<td width="1" height="1" valign="top"><img border="0" src="img/td_01.gif"></td>
<td height="1" background="img/td_02.gif" width="*" valign="top">
<div align="justify"><table border="0" width="100%"><tr><td width="100%" align="center">
<b><font color="#FFFFFF">(六)組件的應用范例</font></b>
</tr></table></div>
</td>
<td width="1" height="1" valign="top"><img border="0" src="img/td_03.gif"></td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" class=Table2 align="center">
<tr>
<td>
<table border="0" width="95%" height="1" bgcolor="#000000" cellspacing="1" cellpadding="2" align="center">
<tr>
<td width="100%" CLASS=CODEBODY1>
<span class="title">上傳表單</span>
</td>
</tr>
<tr>
<td CLASS=CODEBODY2>說明:在表單文件中建立一個表單,表單中有數個文件控件和其他控件</td>
</tr>
<tr>
<td CLASS=CODEBODY2 valign="top">
范例:以上傳一個文件控件<DIV class="code">
<form METHOD="POST" ENCTYPE="multipart/form-data"
ACTION="demo.asp"><br>
選擇文件:<input type="file" name="file1">&nbsp;<input type="submit" value="上載"><br>
</form></DIV>
</td>
</tr>
</table>
<table border="0" width="95%" height="1" bgcolor="#000000" cellspacing="1" cellpadding="2" align="center">
<tr>
<td width="100%" CLASS=CODEBODY1>
<span class="title">保存上傳文件處理</span>
</td>
</tr>
<tr>
<td CLASS=CODEBODY2>說明:在服務器端腳本中使用組件過程</td>
</tr>
<tr>
<td CLASS=CODEBODY2 valign="top">
范例:適用上傳多個文件,定義上傳目錄為“TempUpload/”,文件名以時間日期明名。<DIV class="code">
<%<br>
Dim FormPath<br>
FormPath = "TempUpload/" ''定義上傳路徑<br>
Upload_0<br>
<br>
Sub Upload_0()<br>
Dim Upload<br>
Dim File,FormName,FileName,FileExt,SaveFile<br>
Dim CountSize,UseTime<br>
CountSize = 0</p>
<p>'// 建立上傳對象<br>
Set Upload = Server.CreateObject("DvFile.Upload")</p>
<p>'// 上傳文件類型限制 以 “,” 號分隔<br>
Upload.InceptFileType = "jpg,gif,png,bmp,jpeg"</p>
<p>'// 上傳文件類型限制 以 “,” 號分隔限制大小 :-1為無限,單位
B<br>
Upload.MaxSize = -1</p>
<p>'// 加載上傳數據<br>
Upload.Install</p>
<p>'// 錯誤參數<br>
If Upload.Err > 0 Then<br>
''輸出錯誤信息<br>
Select Case Upload.Err</p>
<blockquote>
<p>'// 錯誤參數請先選擇你要上傳的文件<br>
Case 1 : Response.Write Upload.Description</p>
<p>'// 文件大小超過了限制 "&Upload.MaxSize/1024&"K<br>
Case 2 : Response.Write Upload.Description</p>
<p>'// 非法的上傳類型<br>
Case 3 : Response.Write Upload.Description</p>
<p>'// 所上傳的類型受系統限制<br>
Case 4 : Response.Write Upload.Description</p>
<p>'// 參數有誤,上傳意外中止<br>
Case 5 : Response.Write Upload.Description</p>
</blockquote>
<p>End Select<br>
Response.Write " [ <a href=# onclick=history.go(-1)>重新上傳</a>
]"<br>
Exit Sub<br>
Else</p>
<p>'// 列出所有上傳了的文件<br>
For Each FormName In Upload.File</p>
<p>'// 生成一個文件對象<br>
Set File = Upload.File(FormName)</p>
<p>'// 獲取上傳文件后綴名<br>
FileExt = File.FileExt</p>
<p>'// 格式化上傳路徑<br>
FormPath = FormatPath(FormPath)</p>
<p>'// 定義文件名<br>
FileName = FormatName(FileExt)<br>
SaveFile = FormPath & FileName</p>
<p>'// 如果 FileSize > 0 說明有文件數據<br>
If File.FileSize>0 Then</p>
<p>'// 保存文件<br>
Upload.SaveToFile Server.Mappath(SaveFile),FormName<br>
<br>
'// 輸出信息:<br>
Response.Write "原文件名:" & File.FileName<br>
Response.Write "<BR>"<br>
Response.Write "文件表單名:" & File.FormName<br>
Response.Write "<BR>"<br>
Response.Write "文件來源路徑:" & File.FilePath<br>
Response.Write "<BR>"<br>
Response.Write "文件名:" & FileName<br>
Response.Write "<BR>"<br>
Response.Write "文件類型(File.FileType):" &
File.FileType<br>
Response.Write "<BR>"<br>
Response.Write "文件后綴(File.FileExt):" & File.FileExt<br>
Response.Write "<BR>"<br>
Response.Write "圖像寬(File.FileWidth):" & File.FileWidth<br>
Response.Write "<BR>"<br>
Response.Write "圖像高(File.FileHeight):" &
File.FileHeight<br>
Response.Write "<BR>"<br>
Response.Write "文件大小(File.FileSize):" &
File.FileSize<br>
Response.Write "<BR>"<br>
Response.Write "保存路徑:" & SaveFile<br>
Response.Write "<BR>"<br>
Response.Write "圖片上傳成功!<p>"<br>
End If<br>
Set File=Nothing<br>
Next<br>
Response.Write "共上傳"& Upload.Count &"個文件 ;By
"& Upload.Version &"<p>"<br>
End If</p>
<p>'// 總消耗時間<br>
UseTime = Upload.UseTime</p>
<p>'// 上傳總字節數<br>
CountSize = Upload.TotalBytes<br>
Response.Write "總執行時間:"& UseTime &"亳秒,平均速度:"&
FormatNumber(CountSize/UseTime,2,-1,0,0) &" KB/s."<br>
Set Upload=Nothing<br>
End Sub<br>
<br>
Function FormatPath(Path)<br>
FormatPath = Replace(Path,Chr(0),"")<br>
End Function<br>
<br>
Function FormatName(FileExt)<br>
Dim RanNum<br>
Randomize<br>
RanNum = Int(90000*rnd)+10000<br>
FormatName = Year(now)&Month(now)&Day(now)&Hour(now)&Minute(now)&Second(now)&RanNum&"."&FileExt<br>
End Function<br>
%>
</DIV>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" class=Table2 align="center">
<tr>
<td width="1" height="1" valign="top"><img border="0" src="img/td_05.gif"></td>
<td height="1" background="img/td_06.gif" width="*"><img border="0" src="img/td_06.gif"></td>
<td width="1" height="1" valign="top"><img border="0" src="img/td_07.gif"></td>
</tr>
</table>
<hr width="600" size="1" color="#8C8E94">
<table border="0" cellspacing="1" cellpadding="3" class=Table1 align="center">
<tr>
<td bgcolor="#C0C0C0" align="center">© Copyright 2004 Aspsky, Inc. All Rights Reserved.</td>
</tr>
</table>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -