Saving image file into the database
how can i save the file using c# into the SQL server 开发者_如何学编程dataqbase after user has selected the file location using fileupload control in asp.net .
Please look into this article Save Files to SQL Server Database using FileUpload Control
I would love if you first search on gooogle and than ask for the help if you find out difficult to understand anyways check the following article help you to achieve your task
C# Save and Load Image from Database
You might try something like this:
if (this.fileUploader.PostedFile == null ||
this.fileUploader.PostedFile.ContentLength < 1)
{
this.LabelError.Text = this.GetGlobalResourceObject("Messages", "NoFileToUpload")
.ToString();
return;
}
MyTableWithImageField i = new MyTableWithImageField();
i.ImageData = this.fileUploader.FileBytes;
command.CommandText = @"InsertMyTableWithImageField";
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("@ImageData", i.ImageData);
You may also want to check this from MSDN: Uploading Files in ASP.NET 2.0
精彩评论