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

📄 index.htm

📁 这是一个成熟的文件上传组件,支持多功能文件上传,可以直接运用于项目中.
💻 HTM
📖 第 1 页 / 共 2 页
字号:
	<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">
  &lt;form METHOD=&quot;POST&quot; ENCTYPE=&quot;multipart/form-data&quot; 
ACTION=&quot;demo.asp&quot;&gt;<br>
  选择文件:&lt;input type="file" name="file1">&amp;nbsp;&lt;input type="submit" value="上载"><br> 
  &lt;/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">
&lt;%<br>
Dim FormPath<br>
FormPath = &quot;TempUpload/&quot; ''定义上传路径<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(&quot;DvFile.Upload&quot;)</p>
<p>'// 上传文件类型限制 以 “,” 号分隔<br>
Upload.InceptFileType = &quot;jpg,gif,png,bmp,jpeg&quot;</p>
<p>'// 上传文件类型限制 以 “,” 号分隔限制大小 :-1为无限,单位 
B<br>
Upload.MaxSize = -1</p>
<p>'// 加载上传数据<br>
Upload.Install</p>
<p>'// 错误参数<br>
If Upload.Err &gt; 0 Then<br>
''输出错误信息<br>
Select Case Upload.Err</p>
<blockquote>
  <p>'// 错误参数请先选择你要上传的文件<br>
  Case 1 : Response.Write Upload.Description</p>
  <p>'// 文件大小超过了限制 &quot;&amp;Upload.MaxSize/1024&amp;&quot;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 &quot; [ &lt;a href=# onclick=history.go(-1)&gt;重新上传&lt;/a&gt; 
]&quot;<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 &amp; FileName</p>
<p>'// 如果 FileSize &gt; 0 说明有文件数据<br>
If File.FileSize&gt;0 Then</p>
<p>'// 保存文件<br>
Upload.SaveToFile Server.Mappath(SaveFile),FormName<br>
<br>
'// 输出信息:<br>
Response.Write &quot;原文件名:&quot; &amp; File.FileName<br>
Response.Write &quot;&lt;BR&gt;&quot;<br>
Response.Write &quot;文件表单名:&quot; &amp; File.FormName<br>
Response.Write &quot;&lt;BR&gt;&quot;<br>
Response.Write &quot;文件来源路径:&quot; &amp; File.FilePath<br>
Response.Write &quot;&lt;BR&gt;&quot;<br>
Response.Write &quot;文件名:&quot; &amp; FileName<br>
Response.Write &quot;&lt;BR&gt;&quot;<br>
Response.Write &quot;文件类型(File.FileType):&quot; &amp; 
File.FileType<br>
Response.Write &quot;&lt;BR&gt;&quot;<br>
Response.Write &quot;文件后缀(File.FileExt):&quot; &amp; File.FileExt<br>
Response.Write &quot;&lt;BR&gt;&quot;<br>
Response.Write &quot;图像宽(File.FileWidth):&quot; &amp; File.FileWidth<br>
Response.Write &quot;&lt;BR&gt;&quot;<br>
Response.Write &quot;图像高(File.FileHeight):&quot; &amp; 
File.FileHeight<br>
Response.Write &quot;&lt;BR&gt;&quot;<br>
Response.Write &quot;文件大小(File.FileSize):&quot; &amp; 
File.FileSize<br>
Response.Write &quot;&lt;BR&gt;&quot;<br>
Response.Write &quot;保存路径:&quot; &amp; SaveFile<br>
Response.Write &quot;&lt;BR&gt;&quot;<br>
Response.Write &quot;图片上传成功!&lt;p&gt;&quot;<br>
End If<br>
Set File=Nothing<br>
Next<br>
Response.Write &quot;共上传&quot;&amp; Upload.Count &amp;&quot;个文件 ;By 
&quot;&amp; Upload.Version &amp;&quot;&lt;p&gt;&quot;<br>
End If</p>
<p>'// 总消耗时间<br>
UseTime = Upload.UseTime</p>
<p>'// 上传总字节数<br>
CountSize = Upload.TotalBytes<br>
Response.Write &quot;总执行时间:&quot;&amp; UseTime &amp;&quot;亳秒,平均速度:&quot;&amp; 
FormatNumber(CountSize/UseTime,2,-1,0,0) &amp;&quot; KB/s.&quot;<br>
Set Upload=Nothing<br>
End Sub<br>
<br>
Function FormatPath(Path)<br>
FormatPath = Replace(Path,Chr(0),&quot;&quot;)<br>
End Function<br>
<br>
Function FormatName(FileExt)<br>
Dim RanNum<br>
Randomize<br>
RanNum = Int(90000*rnd)+10000<br>
FormatName = Year(now)&amp;Month(now)&amp;Day(now)&amp;Hour(now)&amp;Minute(now)&amp;Second(now)&amp;RanNum&amp;&quot;.&quot;&amp;FileExt<br>
End Function<br>
%&gt;
</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">&copy; Copyright 2004 Aspsky, Inc. All Rights Reserved.</td> 
    </tr>
  </table>
</body>
</html>

⌨️ 快捷键说明

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