Saving and reading of asp.net files in binary form database

Source: Internet
Author: User

asp.net the files in the binary save and read the form database

Data Sheet Section

 

Front desk-file_upload.aspx

<%@ Page language= "C #" autoeventwireup= "true" codefile= "File_Upload.aspx.cs" inherits= "File_upload"%>

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<title> multi-File upload </title>

<script language= "JavaScript" >

function AddFile ()

{

var str = ' <input type= "file" size= "name=" file ">"

document.getElementById (' MyFile '). insertAdjacentHTML ("BeforeEnd", str)

}

</script>

<body>

<form id= "Form2" method= "POST" runat= "server" enctype= "Multipart/form-data" >

<div align= "center" >

<p id= "MyFile" ><input type= "file" size= "$" name= "file" ></P>

<P>

<input type= "button" value= "Add" onclick= "AddFile ()" >

<input onclick= "This.form.reset ()" type= "button" value= "Reset" >

<asp:button runat= "Server" text= "Start uploading" id= "Button1" onclick= "Uploadbutton_click" ></asp:Button>

</P>

<P>

<asp:label id= "strstatus" runat= "server" font-names= "Arial" font-bold= "True" font-size= "9pt"

Width= "500px" borderstyle= "None" bordercolor= "white" ></asp:Label>

</P>

<br/>

<asp:gridview id= "GridView1" runat= "Server" autogeneratecolumns= "False" width= "335px" onrowcommand= "Gridview_" Rowcommand ">

<Columns>

<asp:boundfield datafield= "id" headertext= "id"/>

<asp:boundfield datafield= "Name"/>

<asp:buttonfield buttontype= "Image" commandname= "Download" headertext= "Download" imageurl= "~/images/mailto.gif"

text= "Download"/>

</Columns>

</asp:GridView>

</div>

</form>

</body>

</HTML>

Background: File_Upload.aspx.cs

Using System;

Using System.Data;

Using System.Configuration;

Using System.Collections;

Using System.Web;

Using System.Web.Security;

Using System.Web.UI;

Using System.Web.UI.WebControls;

Using System.Web.UI.WebControls.WebParts;

Using System.Web.UI.HtmlControls;

Using System.IO;

Using SYSTEM.DATA.SQL;

Using System.Data.SqlClient;

public partial class File_Upload:System.Web.UI.Page

{

private string connstring;

private void Initaldb ()

{

String uid = System.Configuration.ConfigurationManager.AppSettings.Get ("UID");

string pwd = System.Configuration.ConfigurationManager.AppSettings.Get ("pwd");

String server = System.Configuration.ConfigurationManager.AppSettings.Get ("server");

string database = SYSTEM.CONFIGURATION.CONFIGURATIONMANAGER.APPSETTINGS.G

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.