[心缘地方]同学录
首页 | 功能说明 | 站长通知 | 最近更新 | 编码查看转换 | 代码下载 | 常见问题及讨论 | 《深入解析ASP核心技术》 | 王小鸭自动发工资条VBA版
登录系统:用户名: 密码: 如果要讨论问题,请先注册。

[本站胡乱翻译]AspUpload组件的方法中文说明

上一篇:[本站胡乱翻译]AspUpload组件的属性中文说明
下一篇:[本站胡乱翻译]AspUpload组件的方法中文说明---文件对象的属性

添加日期:2006/3/21 15:28:17 快速返回   返回列表 阅读17157次
UploadManager Methods
======================================================
Sub CopyFile (FromPath As String, ToPath As String, Optional Overwrite) 
复制文件。
Overwrite 默认为True。如果设置为False,当目标路径存在时,这个方法会失败。

用法:
Upload.CopyFile "c:\path1\file.ext", "c:\path2\file.ext" 
-------------------------------------------
Sub CreateDirectory (Path As String, Optional IgnoreAlreadyExists) 
建立目录。
IgnoreAlreadyExists 默认为False。如果设置为True,当目标路径存在时,这个方法不会报错。

用法:
Upload.CreateDirectory "c:\dir1\dir2", True 
-------------------------------------------
Sub CreateFile (Path As String) 
建立一个空文件。

用法:
Upload.CreateFile "c:\path\file.txt" 

-------------------------------------------
Sub DecryptAndSendBinary (Path As String, IncludeContentType As Boolean, ContentType As String, Key As CryptoKey, RemoveExt As Boolean, Optional Attachment, Optional FileName) 

和SendBinary相同,但是发送之前会使用Key对文件进行编码,这个Key可以由AspEncrypt组件生成。

RemoveExt参数指定下载框中是否显示文件的扩展名。

如果Attachment参数设置为True,输出的Header中Content-Disposition 将包括关键字"attachment;",以强迫IE下载这个文件。 

FileName参数, 指定下载框中显示的文件名。

用法:
Upload.DecryptAndSendBinary "c:\dir\file.txt.xxx", True, "application/octet-stream", Key, True, True 

-------------------------------------------
Sub DeleteFile (Path As String) 
删除文件。

用法:
Upload.DeleteFile "c:\path\file.txt" 
-------------------------------------------
Function FileExists (Path As String) As Boolean 
检测文件是否存在。

用法:
if Upload.FileExists("c:\path\file.txt") Then ... 
-------------------------------------------
Sub FromDatabase (Connect As String, SQL As String, Path As String) 
使用ODBC,从数据库的表中输出BLOB字段到硬盘。
Connect 指定ODBC连接字符串。 
SQL 该SQL语句应该返回一条记录,这个记录应该包括Blob字段。
Path 完整的文件路径,包括文件名。

用法:
Upload.FromDatabase "DSN=mydb;UID=sa;PWD=xxx;", "select image_blob from myimages where id = 3", "c:\path\file.txt" 
-------------------------------------------
Sub FromRecordset (RecorsetValue As Variant, Path As String) 
使用ADO Recordset 对象从数据库的表中输出BLOB字段。

RecordsetValue 是一个recordset字段,比如rs("image_blob").Value。

Path 完整的路径,包括文件名。

用法:
Set rs = Server.CreateObject("adodb.recordset")
rs.Open "MYIMAGES", Connect, 2, 3
Upload.FromRecordset rs("image_blob").Value, "c:\path\file.txt" 
-------------------------------------------
Sub LogonUser (Domain As String, Username As String, Password As String, Optional Flags) 
扮演指定的用户帐号。 

如果Domain 是空的,那么本机将会验证这个密码。

如果您当前的安全设置不允许你执行上传到远程机器或者其他操作,可以使用这个方法。

Flags 可以是以下值: LOGON_INTERACTIVE (2, default), LOGON_NETWORK (3), LOGON_BATCH (4), and LOGON_SERVICE (5)。不推荐使用这个可选参数。


用法:
Upload.LogonUser "domain", "jsmith", "xxxxxx" 
-------------------------------------------
Sub MoveFile (FromPath As String, ToPath As String) 
移动文件。如果目标路径存在,这个方法将会报错。

用法:
Upload.MoveFile "c:\path1\file.ext", "c:\path2\file.ext" 
-------------------------------------------
Function OpenFile (Path As String) As Object 
建立一个UploadedFile 实例,它指向指定的文件。
如果你想使用UploadedFile.Binary属性的优势,保存任意文件到数据库,这个方法很有用。

用法:
Set File = Upload.OpenFile("c:\path1\file.ext") 
-------------------------------------------
Sub RegisterServer (Path As String, Optional Register) 
模仿 REGSVR32 (/u)的动作。 注册或者卸载指定的ActiveX DLL. 

如果Register参数为True或忽略,为注册DLL, 否则为卸载。

用法:
Upload.RegisterServer "c:\path1\file.dll"

Upload.RegisterServer "c:\path1\file.ocx", False
-------------------------------------------
Sub RemoveDirectory (Path As String) 
删除目录,如果目录包含文件或子目录,会报错。

用法:
Upload.RemoveDirectory "c:\path" 
-------------------------------------------
Sub RevertToSelf
结束由 LogonUser方法开始的扮演。
通常不需要调用这个方法,角色扮演会自动结束。

用法:
Upload.RevertToSelf 
-------------------------------------------
Function Save (Optional Path, Optional Key, Optional Ext) As Long 
最主要的方法。捕获文件,保存到硬盘或内存,组装Files和Form集合。

Path参数, 如果指定,则是文件保存到的路径。

如果Path参数被忽略,文件保存到内存,可以通过File.Binary存取,或者通过File.SaveAs保存到硬盘。

参数Key和Ext,用来加密上传的文件。

Key是一个CryptoKey对象,它由AspEncrypt组件生成。如果指定这个参数,文件保存之前将会被加密。

Ext是可选扩展名。

方法返回值:成功保存的文件数。

用法:

Count = Upload.Save ' save to memory

Count = Upload.Save("c:\upload") ' save to hard drive

Upload.Save "c:\upload" ' save to hard drive, ignore return value

Upload.Save , Key, "xxx" ' Save to memory, encrypt with Key

Upload.Save "c:\upload", Key, "xxx" ' Save to hard drive, encrypt with Key
-------------------------------------------
Function SaveEncrypted (Path As String, Key As Object, Ext As String) As Long 
此方法废止。 只用来向后兼容。用Save方法替代。

Upload.SaveEncrypted(Path, Key, Ext)
等价于
Upload.Save(Path, Key, Ext) 
-------------------------------------------
Function SaveToMemory As Long 
此方法废止。 只用来向后兼容。用Save方法替代。

Upload.SaveToMemory
等价于
Upload.Save 
-------------------------------------------
Function SaveVirtual (Optional VirtualPath, Optional Key, Optional Ext) As Long 

和Save方法相同,但是参数为虚拟路径,而不是物理路径。 

方法内部调用Server.MapPath方法转换虚拟路径为物理路径。

因此, Upload.SaveVirtual(path) 等价于Upload.Save(Server.MapPath(path))。

在Web主机环境里,系统管理员可以禁止Save方法,强迫AspUpload用户使用SaveVirtual方法,以便限制他在自己的目录中进行操作。

用法:
Upload.SaveVirtual "/images"
Upload.SaveVirtual "/images", Key, "xxx" 
-------------------------------------------
Function SaveVirtualEncrypted (Optional VirtualPath, Optional Key, Optional Ext) As Long 
此方法废止。 只用来向后兼容。用SaveVirtual方法替代。
-------------------------------------------
Sub SendBinary (Path As String, Optional IncludeContentType, Optional ContentType, Optional Attachment, Optional FileName) 

用作文件下载。
取得指定的文件,发送给客户端浏览器。
参数IncludeContentType默认为True。
它控制着是否建立Content-Type, Content-Disposition 和Content-Length 这些Header信息. 如果设置为False,这些Header信息不会建立。

ContentType 指定Content-Type header。

Attachment 默认为False。如果设置为True,“Content-Disposition” header 将包括“attachment”关键字,强迫浏览器弹出下载框,而不是在浏览器中打开。

FileName 指定下载框中的文件名。
用法:

Upload.SendBinary "c:\path\file.ext", True, "application/octet-stream", True 
-------------------------------------------
Sub SetMaxSize (MaxSize As Long, Optional Reject) 
指定单个文件的限定大小。
参数Reject 指定过大的文件是否会拒绝(True的时候)或截取(False或省略的时候。)。

用法:
Upload.SetMaxSize 150000, True 
------------------------------------------- 
Sub ToDatabaseEx (Path As String, Connect As String, SQL As String, Optional MSAccessHeaders) 
保存任意的文件到数据库。
查看UploadedFile.ToDatabase 方法。

用法:
Upload.ToDatabaseEx "c:\path\file.txt", "DSN=mydb;", "insert into myimages(image_blob) values(?)" 
-------------------------------------------
 

评论 COMMENTS
没有评论 No Comments.

添加评论 Add new comment.
昵称 Name:
评论内容 Comment:
验证码(不区分大小写)
Validation Code:
(not case sensitive)
看不清?点这里换一张!(Change it here!)
 
评论由管理员查看后才能显示。the comment will be showed after it is checked by admin.
CopyRight © 心缘地方 2005-2999. All Rights Reserved