使用ASP.NET上傳多個文件到數據庫

如果僅僅是上傳一個文件,最好是使用FileUpload控件,  可以使用FileUpload1.FileContent.Length得到文件大小,  FileUpload1.FileBytes得到其字節數組, 代碼略.

如果要上傳多個文件, 其客戶端代碼與使用ASP.NET上傳多個文件到服務器基本相同, 本例中加入了下載的示例代碼。

效果圖如下:

多文件上傳到數據庫

數據庫腳本

create database FileDB
go
use FileDB
go
create table dbo.Files
(
	id int identity primary key
	,FileName varchar(50) not null
	,FileSize int not null
	,FileData image not null
	--,UpTime DateTime default getdate()
	--,DownLoadTimes int default 0
)
go

頁面代碼:MutlileFileUploadToDB.aspx

後臺代碼:MutlileFileUploadToDB.aspx.cs

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章