ASP implementation of the image stored

Source: Internet
Author: User
The use of ASP to write Web applications for a long time, will inevitably encounter a variety of problems, including how to upload files to the service


I am afraid to meet the most problems, especially upload pictures, such as you want to achieve in their own community like NetEase


Virtual Community provides a "daily one star" function, it is necessary to provide users with the ability to upload photos. Uploading picture files to service


can use a variety of free file upload components, although the function is very powerful, but because of many cases, we


can only use the free space to support ASP or rent other people's virtual space, for the first case, we have no


It is possible to use the file upload component; As for the second case, we have to pay a lot of "silver" to do so. Unless you
.

has its own virtual host, you can easily install on the server itself required components, this situation for the big


Most people are expected to be. So there's no way we can do that? Oh, the answer is yes (certainly the


, otherwise I can not write this article AH). Let's take a look at it. Using pure ASP code to realize the
of the picture

upload and save to the database function (in the way also realize the display of pictures in the database to the function of the Web page).


first, let's familiarize ourselves with the object method that will be used. We used to get the data from the previous page. A


use the Request object. Similarly, we can use the request object to get the uploaded file data so that the

The method used for
is Request.BinaryRead (). And we're going to read from the database that the picture's data is displayed on the page to

The
method is:


Request.binarywrite (). When we get the data of the picture, we must save it to the database, we can not directly

Instead of using the INSERT statement to manipulate the database,
uses the AppendChunk method of ADO and, similarly, reads out the database

Picture data in
, use the GetChunk method. The specific syntax for each method is as follows:


*request.binaryread Syntax:


Variant=request.binaryread (count)


parameter


Variant

The
return value is stored to read from the client to the data.


Count


indicates the amount of data to be read from the client, which is less than or equal to the request.totalbytes obtained by using the method


the amount of data.


*request.binarywrite Syntax:


Request.binarywritedata


parameter


Data


the packet to be written to the client browser.


*request.totalbytes Syntax:


variant=request.totalbytes


parameter


Variant


returns the number of bytes read from the client to the amount of data.


*appendchunk Syntax


appends data to large text, binary data field, or parameter objects.


object. Appendchunkdata


parameter


Objectfield or Parameter objects


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.