// Development Environment: Windows 2000, SQLServer2000, And. Net Framework SDK official version
// Development language: C #, ASP. Net
// Introduction: Saving and reading images in the database
// Author: engine
/*
Note: In ASP, we use Request. totalBytes, Request. binaryRead () is used to upload images. This hateful BinaryRead () method is very stupid. It is no big deal to upload a single file. It takes a lot of effort to upload a single image ...! Now ASP. Net will solve all the problems of File Uploading in ASP, so that you can easily release the powerful upload program in ASP. Net. Let's take a look at the example below.
*/
// Note: Due to the limited author level, errors are inevitable. If you find any errors, please advise.
// Email: e_engine@21cn.com
/*
First, create an image storage database table in SQL Server. ImageData Column is the binary data storage field of the image, and ImageContentType Column is the record field of the image file type, imageDescription Column is the description field of the saved image file, and ImageSize Column is the length field of the saved image file. The structure is as follows:
Create table [dbo]. [ImageStore] (
[ImageID] [int] IDENTITY (1, 1) not null,
[ImageData] [image] NULL,
[ImageContentType] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL,
[ImageDescription] [varchar] (200) COLLATE Chinese_PRC_CI_AS NULL,
[ImageSize] [int] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
*/
// The content of UpLoadImage. aspx is as follows:
<% @ Page Inherits = "UploadImage. UploadImage" SRC = "UpLoadImage. cs" Language = "C #" %>
<HTML> <title> upload an image </title>
<BODY bgcolor = "# FFFFFF">
<Form enctype = "multipart/form-data" RUNAT = "server" ID = "Form1">
<Table runat = "server" WIDTH = "700" ALIGN = "left" ID = "Table1" cellpadding = "0" cellspacing = "0" border = "0">
<TR>
<TD> upload an image (select the image you want to upload) </TD>