Al Ain asp No component upload Class (upload component) documentation (from www.sysoft.cc)

Source: Internet
Author: User
Tags save file

Al Ain asp No component upload Class (upload component) documentation
2010-1-18 by Anlige
First, Introduction
Since the contact ASP began to contact upload, saw some upload class, but always feel that the package is not simple enough, so I try to
Write an upload class that allows you to upload in the simplest possible way with the least amount of code.
In the school period began to write, a little bit of perfection, optimization, to the current version, the current version can adapt to various upload methods. On
The main functions of the pass class are as follows:
1, free to set the maximum upload size, single file maximum upload size
2. Freely set the type of files allowed to upload
3, can set the text encoding, to adapt to the various upload environment
4, built-in progress bar, a user can choose to open and close
5, a variety of error status processing
6, a variety of file saving method: The original file name, random file name, user-defined file name
7. Freely choose whether to overwrite existing files
8, complete save form data, support the same name form, does not support the same name file field
Attention:
1, pay special attention to the form must be added enctype= "Multipart/form-data" attribute, method property value must be post, no
The upload will go wrong
2, Request.Form () method to obtain data invalidation, please use upload.forms ()
3, before uploading, please confirm that the folder to save the file has read and write permissions, if not writable will appear "file cannot write" error, workaround
http://dev.mo.cn/show.asp?id=81
Ii. Method of Invocation
1, the method of calling no component class:
Dim Upload
Set Upload = new Anupload
2, the method of calling the component:
Dim Upload
Set Upload = server. CreateObject ("Jo.upload")
Note: The settings for the upload property must precede the call to Upload.getdata ().
Simple Invocation Example:
Dim Upload
Set Upload=new anupload ' Set Upload = Server. CreateObject ("Anasp.anupload")
upload.singlesize=1024*1024*1024 ' Sets the maximum upload limit for a single file, in bytes; default is no Limit
upload.maxsize=1024*1024*1024 ' Set maximum upload limit, in bytes; default is unlimited
Upload.exe= "Bmp|rar|pdf|jpg|gif" ' Set the legal extension to | split
Upload.charset= "gb2312" to set text encoding, default to GB2312
Upload.openprocesser=false ' Disable progress bar function, if enabled, need to cooperate with client program
Upload.getdata () ' Get and save data, you must call this method
Iii. Description of the class
Upload involves 2 classes of-anupload (key upload Class) and UploadFile (file class, save file related information), respectively
Description
1, Anupload (Key upload Class)
Property: Property name read/write description
Mode only writes the data read method, the suggestion uses the default value, the performance is better.
MaxSize writes only the maximum number of bytes allowed to upload.
Singlesize writes only the maximum number of bytes allowed for an uploaded single file.
Exe writes only the extensions that are allowed to be uploaded, separated by |. Do not set it to allow all. *
Also matches all
CharSet write-only set encoding, default is GB2312. If you are using the Utf-8 page,
Please set to Utf-8
ErrorID read-only upload process error ID number, greater than 0 means upload error
FileCount number of read-only uploaded files
Description read-only upload process description, ErrorID greater than 0 is a description of the error
Version read-only upload class/component revision number
TotalSize total size of a read-only upload file
ProcessID read-only process ID with no flush upload, passed by client
Openprocesser write only if the progress bar is turned on
Losttime read-only upload time, not including the time to save the file
Method:
Method Prototype Description
GetData () handles uploaded data with no parameters and no return value
GetSize (Byval size) function formats numbers as directly identifiable file size representations
Parameter size: required, number representation of file size
The text representation of the file size after the returned value is formatted
Description For example, 1024 returns 1KB
Forms (Byval formname) effects get form data
Parameter FormName: Name of the form, required
return value Form Value
Description if FormName is-1, returns a single containing all the form items
Dictionary Object
Files (Byval formname) function get file class
Parameter FormName: Name of the file field, required
The return value contains the file class for the file information. For more information about the class, refer to
UploadFile's description
Description if FormName is-1, returns a file containing all the uploaded
A Dictionary object
2, UploadFile (File Class (object), save file related information)
Because this class (object) is a JScript object and its properties are read-write, some properties that are handled automatically by the program are not recommended
User writes. Property:
Property name Description
FormName file Domain name (Name property)
NewName program automatically generated file name (time + random number)
LocalName Original file name
FileName saved to hard disk file name, valid after calling SaveToFile
Usersetname user-defined file name with no extension
ContentType File types
Size File sizes
Value file data
Path of the directory where the path file is saved on the server
Extend file extension
Method:
Method Prototype Description
SaveToFile
(Path,option,overwrite)
function to save uploaded files to the server
Parameter path: File save path, required. Supports relative paths and absolute roads
Diameter
Option: The file name is defined in a way that is optional.
The default is 0, the file is automatically generated by the program name saved;
-1, if the user has set a custom file name, use the user's own
The defined file name is saved;
1, save with the original file name.
OverWrite: Whether to overwrite files with the same name.
The default is true, overwriting files of the same name;
False, does not overwrite the file with the same name, if there is a file with the same name,
Name file (plus a number after the file name)
Return value file Save result object
Indicates that the returned object has two properties.
Property Error:true (Save failed)/false (saved successfully)
Attribute Description: Save the result description
GetBytes () function gets the binary data of the file
Parameter None
Binary data for return value files
Describes the retrieval of binary data for a file, which is convenient for other programs to process, such as
AspJpeg components, etc.
CreateFolder (FolderPath) function automatically creates a nonexistent directory
Parameter folderpath: The file path to be created, the required return value is None
Description
GetFilePath () automatically renames files with the same name
Iv. about
Anlige (Al Ain, Aien)
Home:/HTTP dev.mo.cn
Mailbox:[email protected]
Five, copyright information
This note is valid for "Al Ain asp No component upload Class" and "Al Ain asp upload components". This type of copyright belongs to the original author, you
For free use of this class (component) with no functional limitations, keep the relevant descriptive information within the class file.
Thank you very much for your support of this class (component).
My other resources: http://dev.mo.cn/download.html

Al Ain asp No component upload Class (upload component) documentation (from www.sysoft.cc)

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.