[英]Saving image file into the database
在用戶使用 asp.net 中的文件上傳控件選擇文件位置后,如何使用 c# 將文件保存到 SQL 服務器數據庫中。
如果您首先在 google 上搜索,我會很高興,如果您發現無論如何都難以理解,請尋求幫助,請查看以下文章幫助您完成任務
你可以嘗試這樣的事情:
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);
您可能還想從 MSDN 中查看: Uploading Files in ASP.NET 2.0
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.