如何使用AspUpload2.0组件?
时间:2010-06-05 12:33:00
下面我们用HTML来上传3个文件看看,它包含了文本描述字段和多项选择:
upload.htm
<HTML>
<BODY BGCOLOR="#FFFFFF">
<FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="upload.asp">
<INPUT TYPE=FILE NAME="FILE1"><BR>
<INPUT TYPE=FILE NAME="FILE2"><BR>
<INPUT TYPE=FILE NAME="FILE3"><BR>
<INPUT TYPE=TEXT NAME="DESCRIPTION"><BR>
<SELECT NAME="CATEGORY" MULTIPLE>
<OPTION>文档
<OPTION>图像
<OPTION>文本
<OPTION>源代码
</SELECT><BR>
<INPUT TYPE=SUBMIT VALUE="现在上传">
</FORM>
</BODY>
</HTML>
upload.asp
<%
Set Upload = Server.CreateObject("Persits.Upload.1")
Upload.OverwriteFiles = False
' 文件名唯一
Upload.SetMaxSize 1048576
' 限制文件在1MB以内
Upload.Save "c:\upload"
For Each File in Upload.Files
' 处理收到的文件
File.ToDatabase "DSN=data;UID=sa;PWD=zzz;", _
"insert into mytable(blob) values(?)"
' 保存到数据库
File.Copy "d:\archive\" & File.ExtractFileName
File.Delete
' 移动到另外的位置
Next
Response.Write Upload.Form("Description") & "<BR>"
' 显示描述字段
For Each Item in Upload.Form
If Item.Name = "Category" Then
Response.Write Item.Value & "<BR>"
' 显示所有选定的类别
End If
Next
%>