or
<OBJECT RUNAT=SERVER
PROGID="Persits.Upload.1" ID=Upload>
</OBJECT>
Name | Type (access) | Comments |
Form | Object (read-only) | Returns the Form collection of FormItem objects. Each FormItem object represents a non-file item of the POST form used to upload the files. You should use this Form collection and not Request.Form because of the special ENCTYPE attribute of the form. |
Files | Object (read-only) | Returns the Files collection of UploadedFile objects. Each UploadedFile object represents a successfully uploaded file coming from an <INPUT TYPE=FILE> item on the POST form. |
Directory | Object (read-only);
Parameters: Path As String;
|
Returns a Directory collection of DirectoryItem objects.
The collection represents a folder on your hard drive. Each DirectoryItem
object represents a file or subdirectory in this folder. Path specifies
a valid path and file name which can contain wildcard characters (* and
?). SortBy specifies how items in the collection will be sorted.
It must be set to one of the Sort-by constant value defined in AspUpload.inc.
The default value for this argument is SORTBY_NAME (numeric 1).
Regardless of the value of SortBy, the subfolder items will always precede file items in the collection, and all items will always be sorted in an ascending order. |
OverwriteFiles | Boolean (read-write) | True by default. If set to False, instructs AspUpload to generate unique file names to prevent overwriting existing files in the upload directory. By default, AspUpload will overwrite existing files. |
PreserveFileTime | Boolean (read-write) | False by default. If you use a browser to upload files, the "Last Modified" dates cannot be preserved because browsers do not send this information along with the file, so the PreserveFileTime property has no effect. However, if you use the XUpload ActiveX control or JUpload Java applet (the latter is currently under development) from Persits Software, Inc. the file date/time information can be preserved by setting this property to True. |
DetectMacBinary | Boolean (read-write) | True by default. AspUpload 2.0+ automatically detects whether an uploaded file is in the MacBinary format, and if so, extracts the "data fork" portion so that the file becomes readable on a PC. If, for any reason, you want to disable this feature, set this property to False. |
IgnoreNoPost | Boolean (read-write) | By default, the Upload.SaveXXX methods will throw the error "Nothing has been posted" if called outside of a <FORM METHOD=POST> handler. This behavior can be suppressed by setting this property to True. This way you can combine both an upload form and upload script in one file with no complicated error trapping necessary. For a usage sample, see the file BothFormAndScript.asp |
Expires | Date (read-only) | Returns the component's expiration date. A registered (non-expiring) version returns 9/9/9999. |
Name | Arguments/Return Values | Comments |
Save | Dir As String.
Return Value: Integer. |
Parses the posting received from a browser and saves all received files in the directory specified. Returns the number of successfully uploaded files. Throws exceptions in case of an error. |
SaveVirtual | VirtDir As String.
Return Value: Integer |
Same as Save, but takes a virtual, rather than physical, directory
as an argument. This method internally calls Server.MapPath, then
calls the Save method. Therefore, Upload.SaveVirtual(VirtDir)
is equivalent to the call Upload.Save(Server.MapPath(VirtDir)).
In a Web hosting environment, the system administrator may disable the Save method so that AspUpload users would be forced to use SaveVirtual only. See the User Manual for more info on disabling AspUpload's advanced features. |
SaveToMemory | Return Value: Integer | Saves uploaded files to memory rather than hard drive for better performance
and security. This method is ideal if the ultimate destination of uploaded
files is a database. To access memory files, use the File.Binary
property.
Returns the number of successfully uploaded files. See the file UploadScript8.asp for a usage sample. |
SaveEncrypted | Dir As String;
Key As CryptoKey; Ext As String; Return Value: Integer. |
Same as Save, but encrypts uploaded files using the Key object creatable by the AspEncrypt component. Appends .Ext (such as .xxx) to the names of encrypted files thus preserving the original file extensions and marking the files as encrypted. For more information, visit the AspEncrypt web site at www.aspencrypt.com/task_upload.html. |
SetMaxSize | MaxSize As Integer;
Optional Reject = False. |
Specified the maximum allowed size of the files to be uploaded. Reject specifies whether files larger than MaxSize should be rejected (if set to True) or truncated (if set to False or omitted). |
LogonUser | Domain As String;
UserID As String; Password As String; Optional Flag = LOGON_INTERACTIVE. |
Impersonates the specified NT account. If Domain
is empty the local computer will be used to validate the password.
Use this function if your current security context does not allow you to perform an upload to a remote machine or certain other operations such as manipulating ACLs. If your virtual directory has the "Run in separate memory space" option enabled, the caller of this method (such as IUSR_machinename) must have the "Act as Part of the operating system" privilege. Otherwise you will recieve the error "Privilege is not held by the client." |
RevertToSelf | none | Ends the impersonation begun by LogonUser. |
SendBinary | Path As String;
Optional IncludeContentType = True; Optional ContentType = ""; Optional Attachment = False (new in AspUpload 2.1) |
Sends the specified file to the browser via Response.BinaryWrite.
If IncludeContentType is set to True or omitted Response.ContentType
will be set to ContentType (if specified), or the appropriate
value based on the file's extension or "application/octet-stream"
if the extension is missing or unknown. The headers Content-Length
and Content-Disposition will be set to the file size and name, respectively.
If IncludeContentType is set to False, the headers will not be set and ContentType will be ignored. Attachment is False by default. If set to True, the Content-Disposition header will contain the keyword attachment; which forces IE 5.0+ to show a "Save this file to disk" dialog box instead of opening the file in-place. |
DecryptAndSendBinary | Path As String;
IncludeContentType As Boolean; ContentType As String; Key As CryptoKey; RemoveExt As Boolean; Optional Attachment = False.(new in AspUpload 2.1) |
Same as SendBinary, but decrypts a file before sending it to the client using the Key object creatable by the AspEncrypt component. RemoveExt specifies whether the file extension appended by SaveEncrypted should be removed from the file name in the Save As dialog. If Attachment is set to True, the Content-Disposition header will be include the keyword "attachment;" to force file downloads under IE. For more information, visit the AspEncrypt web site at www.aspencrypt.com/task_upload.html. |
CreateDirectory | Path As String.
Optional IgnoreAlreadyExists = False |
Creates a new directory and the entire path of sub-directories leading to it, if necessary. If the IgnoreAlreadyExists flag is set to True no error will be thrown if the directory already exists. This is particularly useful if you are uploading entire directories using XUpload. |
RemoveDirectory | Path As String. | Removes a directory. |
CopyFile | FromPath As String;
ToPath As String; Optional Overwrite = True. |
Copies an arbitrary file. FromPath and ToPath must be fully qualified paths. Overwrite, if set to True or omitted, instructs the method to overwrite an existing file. If Overwrite is set to False and a file at ToPath exists, the method will fail |
MoveFile | FromPath As String;
ToPath As String. |
Renames or moves an arbitrary file depending on whether ToPath points to the same or a different directory as FromPath. |
DeleteFile | Path: String | Deletes the specified file. |
CreateFile | Path: String | Creates a zero-length file. |
FileExists | Path: String.
Return Value: Boolean |
Returns True if the specified file exists, False otherwise. |
RegisterServer | DllPath As String;
Optional Register = True. |
Mimics the behavior of REGSVR32 (/u) utility. Registers (unregisters) the specified DLL. If Register is True or omitted, the method registers the DLL, otherwise unregisters it. |
FromDatabase | Connect: String;
SQL: String; Path: String. |
Exports a BLOB from a database table to hard drive. Connect specified an ODBC connection string. SQL is a SELECT statement that must return one record containing a BLOB. The blob data field name must immediately follow the SELECT keyword. Path specifies the destination path. It must be a fully qualified file path, not just a directory name. |
FromRecordset | BlobValue: VARIANT;
Path: String |
Exports a BLOB from a database table using an ADO recordset object.
Path
must be a fully qualified file path, not just a directory name.
For a usage sample, see the file ExportFilesFromDB.asp |
ToDatabaseEx | Path: String;
Connect: String; SQL: String; Optional MSAccessHeaders = False |
Saves an arbitrary file specified by Path to the database. See the UploadedFile.ToDatabase method for the description of parameters Connect,SQL and MSAccessHeaders. |
OpenFile | Path: String;
Return Value: an UploadedFile object. |
Creates an UploadedFile object for an arbitrary file on hard drive.
Useful if you want to take advantage of the UploadedFile.Binary
property to save an arbitrary file to the database using ADO.
For a usage sample, see the file StoredProcedure.asp |
Name | Type (access) | Comments |
Path | String (read-only) | Returns this file's local path. |
OriginalSize | Integer (read-only) | Returns this file's original size. |
OriginalPath | String (read-only) | Returns this file's original path on the client machine. |
Size | Integer (read-only) | Returns this file's current size. It may be different from the original size if, for example, the truncation option was enabled via SetMaxSize. |
Name | String (read-only) | Returns the value of the NAME attribute of this file's <INPUT TYPE=FILE> tag. |
Attributes | Long (read-write) | Returns this file's attributes. Can be a combination of file attribute values defined in AspUpload.inc such as FILE_ATTRIBUTE_READONLY. |
ContentType | String (read-only) | Returns the Content-Type attribute of an uploaded file. |
Binary | VARIANT (read-only) | Returns the Safe-array-of-bytes representation of a file, a format
compatible with ADO. Therefore this property can be used to assign a file
to an ADO recordset field to save a file to the database. For usage samples
see files UploadScript6.asp,
UploadScript8.asp and StoredProcedure.asp. |
ImageHeight
ImageWidth |
Integer (read-only) | Return the image height and width (in pixels) of a GIF, BMP, PNG or JPG file. Return 0 if the underlying file is not in any of these formats, or image size cannot be determined. For a usage sample see the file UploadScript7.asp |
ImageType | String (read-only) | Returns the string "GIF", "BMP", "PNG" or "JPG" if the underlying file is a GIF, BMP, PNG or JPEG image, respectively. Otherwise returns the string "UNKNOWN". |
MD5Hash
(new in AspUpload 2.1) |
String (read-only) | Returns the MD5 one-way hash value in Hex encoding for this file. No two files can have the same hash values, so this property can be used to implement a file identification scheme. |
Name | Arguments/Return Value | Comments |
ExtractFileName | None.
Return value: String |
Extracts filename.ext from the Path property. |
ExtractFolderName | None.
Return value: String |
Extracts the backslash-terminated folder name from the Path property. |
Copy | NewLocation As String;
Optional Overwrite = True. |
Copies this file. NewLocation must be a fully qualified path. Overwrite, if set to True or omitted, instructs the method to overwrite an existing file. If Overwrite is set to False and a file at NewLocation exists, the method will fail. |
CopyVirtual | NewVirtLocation As String;
Optional Overwrite = True. |
Same as Copy, but takes a virtual path as a parameter. Equivalent to Copy(Server.MapPath(NewVirtLocation), Overwrite). |
Move | NewName As String | Renames or moves this file depending on whether NewName points to the same or a different directory. |
MoveVirtual | NewVirtName As String | Same as Move but takes a virtual path as a parameter. Equivalent to Move(Server.MapPath(NewVirtName)) |
Delete | None. | Deletes this file. You may want to use this method when you save the file in the database and no longer need it on your hard drive. |
ToDatabase | Connect As String;
SQL As String; Optional MSAccessHeaders = False |
Saves this file in the database as a blob.
Connect must be in the format "DSN=datasource;UID=userid;PWD=pwd;". SQL must be an SQL INSERT or UPDATE statement with one '?' sign which serves as a place holder for this file. E.g. "insert into blobs(id, theBlob) values(3, ?)" The MSAccessHeaders parameter may only be used with MS Access databases. If set to True, AspUpload will attempt to save the file not as a blob but as an OLE Object so that the document can be invoked directly from MS Access by double-clicking on the table field. This feature will only work with file types for which OLE document servers exist, such as MS Word documents (*.doc), Excel workbooks (*.xls), bitmaps (*.bmp), etc. For other types of files (such as *.gif) the MSAccessHeaders parameter will be ignored and assumed False. |
AllowAccess | AccountName As String;
Flag As Long. |
Adds an allowance access control entity (ACE) corresponding to the specified NT account to this file's Access Control List (ACL). Flag must be a valid combination of Access Type values defined in AspUpload.inc. such as GENERIC_ALL. |
DenyAccess | AccountName As String;
Flag As Long. |
Adds a denial access control entity (ACE) corresponding to the specified NT account to this file's ACL. Flag must be set to GENERIC_ALL. |
RevokeAllowance | AccountName As String | Removes the corresponding allowance ACE from this file's ACL. |
RevokeDenial | AccountName As String | Removes the corresponding denial ACE from this file's ACL. |
SetOwner | AccountName As String | Sets the owner of this file to the NT account specified. |
SaveAs | Path As String | Saves the file represented by this object under the name specified
by Path. If UploadManager.OverwriteFiles is set to False
and a file specified by Path already exists, this method will generate
a unique file name by appending a numeric suffix such as (1), (2), etc.
to the file name.
This method is especially useful when uploading to memory is used. For a usage sample see the file UploadScript11.asp. Side effect: if the method succeeds, the UploadedFile.Path property will be changed to Path (or a unique file name derived from Path) |
Name | Type (access) | Comments |
Name | String (read-only) | Returns the value of the NAME attribute of this item's <INPUT> tag. |
Value (default property) | String (read-only) | Returns the value of the VALUE attribute of this item's <INPUT> tag. |
Name | Type (access) | Comments |
FileName | String (read-only) | Returns file or directory name. |
FileType | String (read-only) | Returns file type according to file extension and registry settings. For subfolders, this value will be set to "File Folder". For files without an extension, this property will be set to "File". For files with extensions that do not have corresponding registry settings (e.g. .xyz) this property will be set to "XYZ File". |
CreationTime | Date (read-only) | Returns file creation date and time. |
LastAccessTime | Date (read-only) | Returns the time this file was last accessed. |
LastWriteTime | Date (read-only) | Returns the time this file was last modified. |
Attributes | Long (read-only) | Returns file attributes. This value can be a combination of File Attribute constant values defined in AspUpload.inc. |
Size | Long (read-only) | Returns file size in bytes. |
IsSubdirectory | Boolean (read-only) | Returns True is the item represents a subdirectory or False if it represents a file. |
Name | Arguments/Return Value | Comments |
CheckAttribute | Attribute As Long;
Return value: Boolean. |
Check if the specified file attribute is present among this file's attributes. Returns True if Attribute is set, False otherwise. Attribute must be set to one of the File Attribute constant values defined in AspUpload.inc such as FILE_ATTRIBUTE_READONLY. |