Implementing images with pure ASP code Uploading into the database We have used data to get the previous page to pass through the data is usually used. Similarly, we can also use the REQUEST object to get uploaded file data, and the method used is request.binaryRead (). The data we have to read from the database is displayed to the method you want to use on the web page is: request.binaryWrite (). When we get the picture of the picture, when you want to save to the database, you cannot use the INSERT statement to operate directly using the ADO's Appendchunk method, the same, read the image data in the database, to use Getchunk method. The specific syntax of each method is as follows: * Request.binaryRead Syntax: Variant = Request.binaryRead (count) Parameter Variant Return Value saves to read the data from the client. Count indicates the amount of data to be read from the client, this value is less than or equal to usage
The amount of data obtained by Request.TotalBytes.
* Request.binaryWrite Syntax:
Request.BinaryWrite Data
parameter
Data
To write the packets in the client browser.
* Request.TotalBytes syntax:
Variant = Request.totalBytes
parameter
Variant
Returns the number of bytes from the client reading to the amount of data.
* Appendchunk syntax
Add data to large text, binary data field or parameter object.
Object.Appendchunk Data
parameter
Object Field or Parameter object
Data variants, including data added to the object.
Description
The Appendchunk method using the Field or Parameter object can use long binary or character
The object is filled in the object. In the case of limited system memory, you can use the Appendchunk method to long
The whole value is partially instead of all operations.
* GetChunk syntax
Returns all or part of the large text or binary data Field object.
Variable = Field.getChunk (size)
return value
Return the variable body.
parameter
Size long integer expressions, equal to the number of bytes or characters to be retrieved.
Description
Some or all long binary or character data are retrieved using the getchunk method of the field object.
In the case where the system is limited, the GetChunk method can be used to handle the part rather than all long integer.
value.
The data returned by the getChunk call will assign it to the "variable". If size is greater than the remaining data, then
GetChunk only returns the remaining data without populating the "variable" with a blank. If the field is empty, then
The getChunk method returns NULL.
Each subsequent GetChunk call will retrieve the number starting from the previous GetChunk call stop.
according to. However, if you retrieve data from a field and then set or read another field in the current record
The value, ADO will consider that data has been retrieved from the first field. If it is adjusted again on the first field
With the getChunk method, ADO will explain the call as a new GetChunk operation and start from the record.
Start reading. If the other Recordset object is not a copy of the first Recordset object,
Visiting the fields do not destroy the getChunk operation.
If the Adfldlong bit in the Attributes property of the Field object is set to True,
Use the getChunk method to this field.
If there is no current record when using the getchunk method on the field object, an error 3021 will be generated
(No current record). Next, we have to design our database, as testing our database structure
Next (Access97):
Field Name Type Description
ID Auto Number Primary key value
IMG OLE object is used to save image data
For the MS SQL Server7, the corresponding structure is as follows:
Field Name Type Description
ID INT (Identity) primary key value
IMG image is used to save image data
Now officially prepared our pure ASP code uploaded part, first of all, we have a mention
The user's upload interface is supplied to allow the user to select the picture to upload. code show as below
(UPLOAD.HTM):