Use ASP code to upload images and store them in the database (2)

Source: Internet
Author: User
* GetChunk syntax
Returns all or part of the Field object of large text or binary data.
Variable = field. GetChunk (Size)
Return value
Returns the variant.
Parameters
Size long integer expression, which is equal to the number of bytes or characters to be retrieved.
Description
Use the GetChunk method of the Field object to retrieve partial or full-length binary or character data. If the system memory is limited, you can use the GetChunk method to process partial rather than all long integer values.
The data returned by the GetChunk call is assigned to the variable ". If the Size is greater than the remaining data
GetChunk only returns the remaining data without filling in the "variable" in the blank space ". If the field is empty
The GetChunk method returns Null.
Each subsequent GetChunk call will retrieve the data starting from the stop of the previous GetChunk call. However, if you retrieve data from a field and then set or read the value of another field in the current record, ADO considers that the data has been retrieved from the first field. If the GetChunk method is called again on the first field, ADO interprets the call as a new GetChunk operation and reads it from the beginning of the record. If other Recordset objects are not copies of the first Recordset object, accessing the fields in them will not destroy the GetChunk operation. If the adFldLong bit in the Attributes attribute of the Field object is set to True, you can use the GetChunk method for this Field. If no current record exists when the Getchunk method is used on the Field object, error 3021 will be generated (no current record ). Next, we will design our database. As a test, our database structure is as follows (Access97 ):
Field name type description
Id auto-numbered primary key value
The img OLE object is used to save image data.
For ms SQL Server 7, 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, we have officially compiled the pure ASP code Upload part. First, we have an upload interface provided to users, allowing users to select the image to be uploaded. The code is as follows:
(Upload.htm ):
<Html>
<Body>
<Center>
<Form name = "mainForm" enctype = "multipart/form-data"
Action = "process. asp" method = post>
<Input type = file name = mefile>
<Input type = submit name = OK value = "OK">
</Form>
</Center>
Related Article

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.