AspUpload Upload component Chinese description document function description

Source: Internet
Author: User
Tags empty header connect odbc sql odbc connection ole string
AspUpload is an ASP extension that allows remote users to upload files through an HTML form. One of its sample scripts allows users to upload files to a WEB server

UploadManager Property
=============================================
CodePage as Long (read/write)
You can convert a form's text item name and file name characters from a specified codepage to Unicode, such as a form that is submitted by UTF-8, and this property should be set to 65001. Others such as 1251 (Cyrillic), 1255 (Hebrew), 1256 (Arabic) and so on.

Usage:
Program code: [Copy Code to clipboard]
Upload.codepage = 65001
-------------------------------------------
Detectmacbinary as Boolean (read/write)
The default is true. This property is used to control whether the uploaded file is macbinary format, and if so, extract "data fork" from it. AspUpload 3.0 Beta 1. Not supported.

Usage:
Upload.detectmacbinary = False
--------------------------------------------
Directory (Path as String, Optional SortBy, Optional Ascending) as Object (read-only)
Returns a collection that contains references to all subdirectories and files for the specified directory.
In this collection, subdirectories always take precedence over files. Path can include wildcard characters * and?.

SortBy can be: sortby_name (1, default). Sortby_type (2), Sortby_size (3), Sortby_creationtime (4), Sortby_lastwritetime (5), and Sortby_lastaccesstime (6).

Ascending defaults to True.

Usage:

<!--METADATA type= "TypeLib" uuid= "{b4e1b2de-151b-11d2-926a-006008123235}"-->
Set Dir = upload.directory ("C:\path\*.*", Sortby_size)
For each Item in Dir
...
Next
-------------------------------------------
Expires as Date (read-only)
If it is already registered, return to 9/9/9999, otherwise the expiration period is returned.

Usage:
Response.Write Upload.expires
-------------------------------------------
Files as Object (read-only)
Returns a collection that contains a reference to the uploaded file.

Before you use this collection, you must invoke the Save or SaveVirtual method.

To refer to a single file, you can use an integer subscript starting with 1, or the name of the corresponding file box.

To enumerate the items in the collection, you can use the For/each statement.

Usage:

Set File = upload.files (1)

Set File = upload.files ("FILE1")

For each File in Upload.files
...
Next
-------------------------------------------
Form as Object (read-only)
Returns a collection that contains all the table single purpose references that are not file boxes.

Before you use this collection, you must invoke the Save or SaveVirtual method.

To refer to a single form item, you can use an integer subscript that starts with 1, or the name of the corresponding item.

To enumerate the items in the collection, you can use the For/each statement.

Usage:

Name = Upload.form (1)

Name = Upload.form ("name")

For each Item in Upload.form
Response.Write Item.value
Next
-------------------------------------------
Ignorenopost as Boolean (read/write)
The "wrong Content-type" error can be avoided when the Upload.Save method is invoked directly by the script, rather than through a form submission. This property is useful when the form and the corresponding upload script are in the same file.

Usage:

Upload.ignorenopost = True
-------------------------------------------
Overwritefiles as Boolean (read/write)
The default is true. If set to False, AspUpload will append "(12)" to the original filename when the filename already exists. This property affects the save, savevirtual, and File.saveas methods.
Usage:

Upload.overwritefiles = False
-------------------------------------------
Preservefiletime as Boolean (read/write)
Default is Flase. If set to true, an attempt is made to protect the last modified time of the uploaded file.
This property is useful only when the client uses Xupload or jupload.
When you use the regular form submission, it has no effect.
Usage:

Upload.preservefiletime = False
-------------------------------------------
Progressid as String (read/write)
Upload the progress bar used to differentiate the upload process.

Usage:

Upload.progressid = Request.QueryString ("PID")
-------------------------------------------
RegKey as String (read/write)
Specifies the registration code, and if not specified, AspUpload reads from the system registry.
Usage:

Upload.regkey = "12345-67890-12345"
-------------------------------------------
TotalBytes as Long (read-only)
Returns the total number of bytes uploaded.
This property can only be invoked after a successful call to the Save (savevirtual) method.

Usage:
Response.Write Upload.totalbytes
-------------------------------------------
TotalSeconds as Long (read-only)
Returns the total time that the upload lasted.
This property can only be invoked after a successful call to the Save (savevirtual) method.

Usage:
Response.Write Upload.totalseconds
-------------------------------------------
Version as String (read-only)
Returns the version number of the component, such as "3.0.0.0".
Usage:

Response.Write Upload.version
-------------------------------------------
UploadManager Methods
======================================================
Sub CopyFile (Frompath As String, Topath as String, Optional Overwrite)
Copy the file.
Overwrite defaults to True. If set to False, this method fails when the target path exists.

Usage:
Upload.copyfile "C:\path1\file.ext", "C:\path2\file.ext"
-------------------------------------------
Sub CreateDirectory (Path as String, Optional ignorealreadyexists)
Create a directory.
Ignorealreadyexists defaults to False. If set to True, this method does not error when the target path exists.

Usage:
Upload.createdirectory "C:\dir1\dir2", True
-------------------------------------------
Sub CreateFile (Path as String)
Create an empty file.

Usage:
Upload.createfile "C:\path\file.txt"

-------------------------------------------
Sub decryptandsendbinary (Path As String, Includecontenttype as Boolean, ContentType as String, Key as Cryptokey, Removeex T as Boolean, Optional attachment, Optional FileName)

Same as Sendbinary, but the file is encoded using key before it is sent, and the key can be generated by the AspEncrypt component.

The Removeext parameter specifies whether the file's extension is displayed in the Download box.

If the attachment parameter is set to True, the content-disposition in the header of the output will include the keyword "attachment;" to force IE to download the file.

FileName parameter, specifying the name of the file to display in the Download box.

Usage:
Upload.decryptandsendbinary "C:\dir\file.txt.xxx", True, "Application/octet-stream", Key, True, True

-------------------------------------------
Sub DeleteFile (Path as String)
Deletes a file.

Usage:
Upload.deletefile "C:\path\file.txt"
-------------------------------------------
Function FileExists (Path as String) as Boolean
Detects whether a file exists.

Usage:
If Upload.fileexists ("c:\path\file.txt") Then ...
-------------------------------------------
Sub fromdatabase (Connect As String, SQL as String, Path as String)
Using ODBC, Output BLOB fields from the tables in the database to the hard disk.
CONNECT specifies the ODBC connection string.
SQL This SQL statement should return a record that should include a BLOB field.
Path complete file paths, including file names.

Usage:
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) uses an ADO Recordset object to Output BLOB fields from a table in a database.

Recordsetvalue is a recordset field, such as RS ("Image_blob"). Value.

Path complete, including the filename.

Usage:
Set rs = Server.CreateObject ("Adodb.recordset")
Rs. Open "MyImages", Connect, 2, 3
Upload.fromrecordset rs ("Image_blob"). Value, "c:\path\file.txt"
-------------------------------------------
The Sub LogonUser (Domain As String, Username as String, Password as String, Optional Flags) acts as the specified user account.

If domain is empty, the computer will validate the password.

This method can be used if your current security settings do not allow you to perform upload to remote machines or other operations.

Flags can be the following values: Logon_interactive (2, default), Logon_network (3), Logon_batch (4), and Logon_service (5). It is not recommended to use this optional parameter.


Usage:
Upload.logonuser "Domain", "jsmith", "xxxxxx"
-------------------------------------------
Sub MoveFile (Frompath As String, Topath as String) moves the file. If the target path exists, this method will have an error.

Usage:
Upload.movefile "C:\path1\file.ext", "C:\path2\file.ext"
-------------------------------------------
Function OpenFile (Path as String) as Object establishes a UploadedFile instance that points to the specified file.
This is useful if you want to use the advantages of the Uploadedfile.binary attribute to save any file to the database.

Usage:
Set File = Upload.openfile ("C:\path1\file.ext")
-------------------------------------------
Sub RegisterServer (Path as String, Optional Register) mimics the actions of REGSVR32 (/u). Registers or uninstalls the specified ActiveX DLL.

If the register parameter is TRUE or ignored, the DLL is registered, or it is uninstalled.

Usage:
Upload.registerserver "C:\path1\file.dll"

Upload.registerserver "C:\path1\file.ocx", False
-------------------------------------------
Sub removedirectory (Path as String)
Deletes a directory, and if the directory contains files or subdirectories, an error occurs.

Usage:
Upload.removedirectory "C:\Path"
-------------------------------------------
Sub RevertToSelf
The play that ends by the LogonUser method begins.
It is not usually necessary to call this method, and role-playing will automatically end.

Usage:
Upload.reverttoself
-------------------------------------------
Function Save (Optional Path, Optional Key, Optional Ext) as Long
The most important method. Capture files, save to hard disk or memory, assemble files and form collections.

Path parameter, if specified, is the path to which the file was saved.

If the path parameter is ignored, the file is saved to memory and can be accessed through file.binary or saved to the hard disk through File.saveas.

Parameter key and ext, used to encrypt uploaded files.

The key is a Cryptokey object that is generated by the AspEncrypt component. If you specify this parameter, the file will be encrypted before it is saved.

EXT is an optional extension.

Method return Value: The number of files successfully saved.

Usage:

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
This method is annulled. For backward compatibility only. Replace with the Save method.

Upload.saveencrypted (Path, Key, EXT)
Equivalent to
Upload.Save (Path, Key, EXT)
-------------------------------------------
Function SaveToMemory as Long
This method is annulled. For backward compatibility only. Replace with the Save method.

Upload.savetomemory
Equivalent to
Upload.Save
-------------------------------------------
Function savevirtual (Optional virtualpath, Optional Key, Optional Ext) as Long

The same as the Save method, but the parameter is a virtual path, not a physical path.

Method Internal call Server.MapPath method transforms a virtual path to a physical path.

Therefore, upload.savevirtual (path) is equivalent to Upload.Save (Server.MapPath (path)).

In a web host environment, a system administrator can disable the Save method and force AspUpload users to use the SaveVirtual method to restrict his operations in his own directory.

Usage:
Upload.savevirtual "/images"
Upload.savevirtual "/images", Key, "xxx"
-------------------------------------------
Function savevirtualencrypted (Optional virtualpath, Optional Key, Optional Ext) as Long
This method is annulled. For backward compatibility only. Replace with SaveVirtual method.
-------------------------------------------
Sub sendbinary (Path as String, Optional Includecontenttype, Optional ContentType, Optional attachment, Optional FileName)

Used as a file download.
Gets the specified file and sends it to the client browser.
Parameter Includecontenttype defaults to True.
It controls whether to establish Content-type, content-disposition, and Content-length header information. If set to False, these header information is not established.

CONTENTTYPE Specifies the Content-type header.

Attachment defaults to False. If set to True, the "Content-disposition" header will include the "attachment" keyword, forcing the browser to eject the download box instead of opening it in the browser.

filename Specifies the name of the file in the download box.
Usage:

Upload.sendbinary "C:\path\file.ext", True, "Application/octet-stream", True
-------------------------------------------
Sub setmaxsize (MaxSize as Long, Optional Reject)
Specifies the qualified size of a single file.
Parameter reject specifies whether a file that is too large will reject (true) or intercept (false or omitted). )。

Usage:
Upload.setmaxsize 150000, True
-------------------------------------------
Sub Todatabaseex (Path As String, Connect as String, SQL as String, Optional msaccessheaders)
Save any files to the database.
View the Uploadedfile.todatabase method.

Usage:
Upload.todatabaseex "C:\path\file.txt", "Dsn=mydb", "INSERT into MyImages (IMAGE_BLOB) VALUES (?)"
-------------------------------------------
UploadedFile Property
================================================
Attributes as Long (read/write)
Sets and gets the system properties of the file.
Can be a combination of the following values.
File_attr_readonly = &h1
File_attr_hidden = &h2
File_attr_system = &h4
File_attr_directory = &h10
File_attr_archive = &h20
File_attr_normal = &h80
File_attr_temporary = &h100
file_attr_compressed = &h800

Usage:
<!--METADATA type= "TypeLib" uuid= "{b4e1b2de-151b-11d2-926a-006008123235}"-->
Response.Write File.attributes

File.attributes = file.attributes + file_attr_readonly
-------------------------------------------------------------
Binary as Variant (read-only)
Returns the binary image of the file. It is a variant-packed safe array of bytes.
Useful when saving files to the database.

Usage:
Rs. AddNew
RS ("Image_blob"). Value = File.binary
Rs. Update
-------------------------------------------------------------
ContentType as String (read-only)
Returns the Content-type of the file.
such as: "Text/plain" or "application/octet-binary".

Usage:
Response.Write File.contenttype
-------------------------------------------------------------
CreationTime as Date (read-only)
Returns the creation timestamp of the file. If it is a memory file, this attribute is not defined.

Usage:
Response.Write File.creationtime
-------------------------------------------------------------
Ext as String (read-only)
Returns the file name extension.

Usage:
Response.Write File.ext
-------------------------------------------------------------
FileName as String (read-only)
Returns the name of the file being saved.
If Upload.overwritefiles is false, it may be different from the original file name.

Usage:
Response.Write File.filename
-------------------------------------------------------------
Folder as String (read-only)
Returns the name of the folder where the file was saved.
If it is a memory file, it is the same as the original folder name.

Usage:
Response.Write File.folder
-------------------------------------------------------------
ImageHeight as Long (read-only)
Returns the pixel height of the picture. If it is not a picture, return 0.
Format supports BMP, JPG, GIF, and PNG.

Usage:
Response.Write File.imageheight
-------------------------------------------------------------
ImageType as String (read-only)
Returns the picture type. Possible return values are "BMP", "GIF", "JPG", "PNG", and "TIF" for BMP, GIF, JPEG, PNG, and TIFF images, respectively, and "UNKNOWN" (if the file is not a picture, or a known picture type.) )

Usage:
Response.Write File.imagetype
-------------------------------------------------------------
ImageWidth as Long (read-only)
Returns the pixel width of the picture. If it is not a picture, return 0.
Format supports BMP, JPG, GIF, and PNG.

Usage:
Response.Write File.imagewidth
-------------------------------------------------------------
LastAccessTime as Date (read-only)
Returns the last access time stamp of a file. If it is a memory file, this attribute is not defined.

Usage:
Response.Write File.lastaccesstime
-------------------------------------------------------------
LastWriteTime as Date (read-only)
Returns the last write timestamp of a file. If it is a memory file, this attribute is not defined.
Unless the file is uploaded by Xupload or Jupload, and the Preservefiletime feature is turned on.

Usage:
Response.Write File.lastwritetime
-------------------------------------------------------------
Md5hash as String (read-only)
Returns the MD5 one-way hash value of the file in hexadecimal.

Usage:
Response.Write File.md5hash
-------------------------------------------------------------
Name as String (read-only)
Returns the name of the corresponding item in the form for the file.
This property cannot get the filename and should use Fielname.

Usage:
Response.Write File.name
-------------------------------------------------------------
OriginalFilename as String (read-only)
Returns the original filename of the file.

Usage:
Response.Write File.originalfilename
-------------------------------------------------------------
Originalfolder as String (read-only)
Returns the original folder of the file.

Usage:
Response.Write File.originalfolder
-------------------------------------------------------------
Originalpath as String (read-only)
Returns the original full path of the file.

Usage:
Response.Write File.originalpath
-------------------------------------------------------------
Originalsize as Long (read-only)
Returns the original size of the file.
This value may be different from the current size if the file is truncated through the Setmaxsize method.

Usage:
Response.Write File.originalsize
-------------------------------------------------------------
Path as Long (read-only)
Returns the full path of the file on the server.

Usage:
Response.Write File.path
-------------------------------------------------------------
Size as Long (read-only)
Returns the size of the file on the server.
If the Setmaxsize attribute is valid, this value may differ from the original size.

Usage:
Response.Write File.size
-------------------------------------------------------------
UploadedFile Methods
======================================================
Sub allowaccess (account as String, Flags as Long)
Adds "Allow access control (ACE)" To the Access Control List (ACL) of the file for the specified NT user.

Parameter flags must be a combination of valid access types, which are defined in Aspupload.inc, such as: Generic_all.

Other valid flag combinations include:

Read (RX): Generic_read + File_generic_execute
Change (RWXD): Generic_read + generic_write + file_generic_execute + DELETE
Full Control (All): Generic_all

Usage:
File.allowaccess "JSmith", Generic_all
----------------------------------------------------------
Sub Copy (Path as String, Optional Overwrite)
Copies the file to the specified path, and this path must have permission.
Overwrite the existing file if the parameter overwrite is set to TRUE or ignored. If set to False and the file already exists under the specified path, an error is made.

Usage:
File.Copy "C:\newpath\" & File.filename
----------------------------------------------------------
Sub copyvirtual (virtualpath as String, Optional Overwrite)
Same as the copy method. However, the parameter is a virtual path, not a physical path.
If the system administrator prohibits the copy method, users are forced to use the Copyvirtual method, which restricts them from operating in their own directory.

Usage:
File.copyvirtual "/uploads/" & File.filename
----------------------------------------------------------
Sub Delete
Deletes a file.

Usage:
File.delete
----------------------------------------------------------
Sub denyaccess (account as String, Flags as Long)
Adds an Access control list (ACL) to a file for the specified NT user by adding Deny access control (ACE).

Parameter flags must be set to Generic_read.

Usage:
File.denyaccess "JSmith", Generic_all
----------------------------------------------------------
Sub Extractfilename
This method is revoked and is used only to maintain backward compatibility. Please use filename.

Usage:
Response.Write File.extractfilename
----------------------------------------------------------
Sub Extractfoldername
This method is revoked and is used only to maintain backward compatibility. Please use folder.
Usage:

Response.Write File.extractfoldername
----------------------------------------------------------
Sub Move (Path as String)
Copies the file to the specified path, and the path must have permissions.

If the file already exists, an error is made.

Side effects: If this method executes successfully, the File.path property is updated to the new path.

Usage:
File.move "C:\newpath\" & File.filename
----------------------------------------------------------
Sub movevirtual (virtualpath as String)
The same as the Move method, but the parameter is a virtual path, not a physical path.

Usage:
File.movevirtual "/uploads/" & File.filename
----------------------------------------------------------
Sub revokeallowance (account as String)
Removes the appropriate allow Aces from the file's ACLs.

Usage:
File.revokeallowance "JSmith"
----------------------------------------------------------
Sub revokedenial (account as String)
Removes the appropriate deny ace from the file's ACL.

Usage:
File.revokedenial "JSmith"
----------------------------------------------------------
Sub SaveAs (Path as String)
Saves the file to the specified path.
If the uploadmanager.overwritefiles is set to False and the file already exists under the specified path, the secondary method appends characters such as (1) (2) to the original file name to generate a unique file name.

This method is the only way to save a memory file to your hard disk.

Side effects: If this method succeeds, Uploadedfile.path will update to the new path (or from his new unique filename.) )。

Usage:
File.saveas "C:\path\" & File.filename
----------------------------------------------------------
Sub saveasvirtual (virtualpath as String)
The same as the Save method. However, the parameter is a virtual path, not a physical path.
If the system administrator prohibits the Save method, the user is forced to use the SaveVirtual method, which restricts them from operating in their own directory.
Usage:

File.saveasvirtual "/path/" & File.filename
----------------------------------------------------------
Sub SetOwner (account as String, Flags as Long)
Specifies the specified NT user as the NTFS owner of the file.

Usage:
File.setowner "JSmith"
----------------------------------------------------------
Sub todatabase (Connect As String, SQL as String, Optional msaccessheaders)
Using ODBC, save the file as a blob to the database.

Parameter connect is an ODBC connection character Fu Yi that can be used with a System DSN, or non-DSN, such as:

"DSN=MYDB; Uid=sa; Pwd=xxxxx "

Or

"Driver={microsoft Access Driver (*.mdb)};D Bq=c:\path\db.mdb"

However, connect cannot make a Ado-style connection string, that is, it cannot involve an old DB provider because the method is ODBC based.

SQL is an INSERT or update SQL statement that uses a question mark as a placeholder for a file saved to the database.

Such as:

"INSERT into MyTable (image_blob, path) values (?, ' C:\path\file.ext ')"

Or

"UPDATE mytable SET imageblob =?" WHERE id = 15 "

The Msaccessheaders parameter can only be used in the MS Access database.

If set to True, AspUpload will attempt to save the file as an OLE object rather than as a blob.
So that the file can be called directly in MS Access by double-clicking the field.

This attribute is valid only if the file type exists in the file type of OLE document servers, such as Ms Word documents (*.doc), Excel Workbooks (*.xls), bitmaps (*.bmp), and so on.

For other types of files, such as *.gif, the parameter msaccessheaders is ignored and is assumed to be false.

Note: You cannot download a file that is saved as an OLE object directly.

Usage:
File.todatabase "DSN=MYDB; Uid=sa; Pwd=xxxx "," INSERT into MyImages (IMAGE_BLOB) VALUES (?) "







Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.