在asp 里 怎么用AspUpload3.0组件上传文件?需要那些具体的配置?具体的上传代码?

cactusjoy 2008-04-28 11:07:41
毕业设计中···请各位多帮帮忙 内容如题···多谢多谢
...全文
658 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
cactusjoy 2008-04-28
  • 打赏
  • 举报
回复
再补充问下···怎么用这个组件上传,并生成一个随机的文件名,然后把文件名存到sql数据库里~·
md5e 2008-04-28
  • 打赏
  • 举报
回复
安装要用破解版注册,否则会出错
No_Data_Found 2008-04-28
  • 打赏
  • 举报
回复
A Simple Upload Form

The following HTML form (located in the sample file Form1.asp) enables a user to select up to three files for uploading to the server:
<HTML>
<BODY BGCOLOR="#FFFFFF">
<FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="UploadScript1.asp">
<INPUT TYPE="FILE" SIZE="40" NAME="FILE1"><BR>
<INPUT TYPE="FILE" SIZE="40" NAME="FILE2"><BR>
<INPUT TYPE="FILE" SIZE="40" NAME="FILE3"><BR>
<INPUT TYPE=SUBMIT VALUE="Upload!">
</FORM>
</BODY>
</HTML>



Notice the ENCTYPE="multipart/form-data" attribute in the <FORM> tag. It instructs the browser to send the entire file to the server and not just the file name entered in the input text box. It is absolutely mandatory that your upload forms contain this attribute, or no uploading can be performed.

This form contains three items <INPUT TYPE="FILE"> which appear on the page as text boxes with the Browse button next to them. Each box can be used to select one file only. While the SIZE attribute of an <INPUT TYPE="FILE"> item is optional, the NAME attribute is required.

This form invokes the upload script UploadScript1.asp shown below:

<HTML>
<BODY>
<%
Set Upload = Server.CreateObject("Persits.Upload")
Count = Upload.Save("c:\upload")
Response.Write Count & " file(s) uploaded to c:\upload"
%>
</BODY>
</HTML>



The first line of the ASP script simply creates an instance of the AspUpload object. The second line calls the Save method of the component which actually performs the upload: it parses the information POSTed by the browser, figures out how many files are being uploaded, and saves them in a specified local directory on the server under their original names.

The Save method returns the number of files successfully uploaded. In case of an error this method will throw an exception.

Click the link below to run this code sample:

http://localhost/aspupload/02_simple/Form1.asp

FILES and FORM Collections
Due to the "multipart/form-data" attribute of upload forms, your ASP script can no longer use the built-in Request.Form collection to access individual form items. AspUpload solves this problem by offering two collections of its own, Upload.Files and Upload.Form to provide access to uploaded files and text fields, respectively.
Upload.Files is a collection of UploadedFile objects which offer access to various properties and attributes of uploaded files, such as filename, path, size, hash value, etc. The UploadedFile object also offers many methods which enable you to manipulate uploaded files (copy, move, save to the database, delete, etc.) Individual items of the collection can be referenced via numeric or string indices, or iterated through via the For-Each statement.

Upload.Form is a collection of FormItem objects that represent text fields on an upload form. Upload.Form is similar to Request.Form and should be used instead of the latter in your upload script. The FormItem object provides two properties, Name and Value.

The use of the Files and Form collections is demonstrated by the sample files Form2.asp and UploadScript2.asp:

<HTML>
<BODY BGCOLOR="#FFFFFF">
<FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="UploadScript2.asp">
File 1:<INPUT TYPE=FILE NAME="FILE1">
Description 1:<INPUT TYPE=TEXT NAME="DESCR1"><BR>
File 2:<INPUT TYPE=FILE NAME="FILE2">
Description 2:<INPUT TYPE=TEXT NAME="DESCR2"><BR>
<INPUT TYPE=SUBMIT VALUE="Upload!">
</FORM>
</BODY>
</HTML>



This form contains both <INPUT TYPE=FILE> and regular <INPUT TYPE=TEXT> items. It invokes the script UploadScript2.asp:

<HTML>
<BODY>
<%
Set Upload = Server.CreateObject("Persits.Upload.1")
Upload.Save "c:\upload"
%>

Files:<BR>
<%
For Each File in Upload.Files
Response.Write File.Name & "= " & File.Path & " (" & File.Size &" bytes)<BR>"
Next
%>

<P>

Other items:<BR>
<%
For Each Item in Upload.Form
Response.Write Item.Name & "= " & Item.Value & "<BR>"
Next
%>
</BODY>
</HTML>



Click the link below to run this code sample:

http://localhost/aspupload/02_simple/Form2.asp

The output should look similar to this:

Files:
FILE1=c:\upload\File1.xls (108544 bytes)
FILE2=c:\upload\File2.zip (211687 bytes)

Other items:
DESCR1=bla bla
DESCR2=test test


IMPORTANT: The Upload.Files and Upload.Form collections are populated by the Upload.Save method. Therefore, it is incorrect to reference either collection before the Save method is called:

' Incorrect!
Upload.Save( Upload.Form("Path") )

No_Data_Found 2008-04-28
  • 打赏
  • 举报
回复
安装完 有详细的实用手册的

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧