Example of accessing images to the database in ASP. NET

Source: Internet
Author: User
// 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>
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.