📄 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 + -