當前位置:首頁 » 操作系統 » 圖像資料庫

圖像資料庫

發布時間: 2022-01-24 21:50:03

㈠ 數據是一張張圖片,那資料庫要怎麼建

把圖片傳到FTP上,確定統一的路徑以及命名規則,如果有需要對圖片進行分類整理,重命名,然後將路徑存到資料庫,調用時只要知道FTP上圖片的路徑就可以顯示圖片了。

㈡ 圖片資料庫怎麼建立

在建立資料庫是應該想好各個數據之間的關系,需要存儲哪些數據,這些數據直接是一對一,一對多還是多對一得關系。一般保存圖片數據的話不建議直接保存圖片,而建議保存圖片的地址,大致需要這么幾個欄位,主鍵,圖片的絕對地址,圖片的大小,圖片的名稱等等

㈢ 圖片如何存入資料庫

通常對用戶上傳的圖片需要保存到資料庫中。解決方法一般有兩種:一種是將圖片保存的路徑存儲到資料庫;另一種是將圖片以二進制數據流的形式直接寫入資料庫欄位中。以下為具體方法:
一、保存圖片的上傳路徑到資料庫:
string uppath="";//用於保存圖片上傳路徑
//獲取上傳圖片的文件名
string fileFullname = this.FileUpload1.FileName;
//獲取圖片上傳的時間,以時間作為圖片的名字可以防止圖片重名
string dataName = DateTime.Now.ToString("yyyyMMddhhmmss");
//獲取圖片的文件名(不含擴展名)
string fileName = fileFullname.Substring(fileFullname.LastIndexOf("\\") + 1);
//獲取圖片擴展名
string type = fileFullname.Substring(fileFullname.LastIndexOf(".") + 1);
//判斷是否為要求的格式
if (type == "bmp" || type == "jpg" || type == "jpeg" || type == "gif" || type == "JPG" || type == "JPEG" || type == "BMP" || type == "GIF")
{
//將圖片上傳到指定路徑的文件夾
this.FileUpload1.SaveAs(Server.MapPath("~/upload") + "\\" + dataName + "." + type);
//將路徑保存到變數,將該變數的值保存到資料庫相應欄位即可
uppath = "~/upload/" + dataName + "." + type;
}
二、將圖片以二進制數據流直接保存到資料庫:
引用如下命名空間:
using System.Drawing;
using System.IO;
using System.Data.sqlClient;
設計資料庫時,表中相應的欄位類型為iamge
保存:
//圖片路徑
string strPath = this.FileUpload1.PostedFile.FileName.ToString ();
//讀取圖片
FileStream fs = new System.IO.FileStream(strPath, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
byte[] photo = br.ReadBytes((int)fs.Length);
br.Close();
fs.Close();
//存入
SqlConnection myConn = new SqlConnection("Data Source=.;Initial Catalog=stumanage;User ID=sa;Password=123");
string strComm = " INSERT INTO stuInfo(stuid,stuimage) VALUES(107,@photoBinary )";//操作資料庫語句根據需要修改
SqlCommand myComm = new SqlCommand(strComm, myConn);
myComm.Parameters.Add("@photoBinary", SqlDbType.Binary, photo.Length);
myComm.Parameters["@photoBinary"].Value = photo;
myConn.Open();
if (myComm.ExecuteNonQuery() > 0)
{
this.Label1.Text = "ok";
}
myConn.Close();
讀取:
...連接資料庫字元串省略
mycon.Open();
SqlCommand command = new
SqlCommand("select stuimage from stuInfo where stuid=107", mycon);//查詢語句根據需要修改
byte[] image = (byte[])command.ExecuteScalar ();
//指定從資料庫讀取出來的圖片的保存路徑及名字
string strPath = "~/Upload/zhangsan.JPG";
string strPhotoPath = Server.MapPath(strPath);
//按上面的路徑與名字保存圖片文件
BinaryWriter bw = new BinaryWriter(File.Open(strPhotoPath,FileMode.OpenOrCreate));
bw.Write(image);
bw.Close();
//顯示圖片
this.Image1.ImageUrl = strPath;
採用倆種方式可以根據實際需求靈活選擇。

㈣ 圖片如何存入資料庫

1、新建一個資料庫,資料庫名為Image,表名為image。並為表添加ID,tupian兩個列。

㈤ 如何建立圖像資料庫

建立,SQLSERVER實現
CREATE TABLE dbo.服裝圖片 (
id int IDENTITY (1, 1) NOT NULL ,
標題 varchar (50) ,
說明 text ,
存放路徑 varchar (50),
圖片尺寸 varchar (50),
其它屬性 varchar (50)
)
操作:
前台語言編寫,可按標題等屬性查詢圖片,或通過GRID控制項顯示列表,通過調入的存放路徑和文件名字串調入到圖片控制項顯示圖片。

㈥ 如何將一jpg圖像存入sql資料庫

用來獲取上一個頁面傳 遞過來的數據一般是使用Request對象。同樣的,我們也可以使用Request對象 來獲取上傳上來的文件數據,使用的方法是Request.BinaryRead()。
要從資料庫中讀出來圖片的數據顯示到網頁上面要用到的方法是:Request.BinaryWrite()。

㈦ 如何製作圖片資料庫

可以使用VB,用VB把圖片放到ACCESS中,然後再讀取出來,實際上是個很簡單的小程序:
Dim cc() As Byte
Dim i
Dim t
Private Sub Command1_Click()
CommonDialog1.Filter = "JPG圖片(*.BMP)|*.BMP"
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
Picture1.Picture = LoadPicture(CommonDialog1.FileName)
strname = CommonDialog1.FileName
Open strname For Binary As #1
ReDim cc(LOF(1) - 1)
t = cc(LOF(1) - 1) '在讀取二進制時,如果是用文件操作那麼涉及到到底從文件中取多少位元組的問題,所以位元組數組要指定大小
Get #1, , cc
Close
Else
MsgBox "沒有選中圖片"
End If
End Sub
Private Sub Command2_Click()
Adodc1.Refresh
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("id") = i
Adodc1.Recordset.Fields("qq") = cc
i = i + 1
Adodc1.Recordset.Update
Adodc1.Refresh
End Sub
Private Sub Command3_Click()
Adodc1.Refresh
Dim P() As Byte
Adodc1.RecordSource = "select qq from 表一 where id='" & Text1.Text & "'"
P = Adodc1.Recordset.Fields("qq") '當把一組二進制數據賦值給一個二進制數組時就不用指定數組的大小了,因為是全部賦值
Open App.Path & "\oo.bmp" For Binary As #1
Put #1, , P
Close
End Sub
Private Sub Command4_Click()
Open App.Path & "\oo.bmp" For Binary As #1
Put #1, , cc
Close
End Sub
Private Sub Form_Load()
i = 1
End Sub

㈧ 圖片如何存儲在資料庫當中

頭條的文件就存在資料庫,可能他們取出來就是二進制吧,播放器可以解碼

熱點內容
ios應用上傳 發布:2024-09-08 09:39:41 瀏覽:438
ios儲存密碼哪裡看 發布:2024-09-08 09:30:02 瀏覽:870
opensslcmake編譯 發布:2024-09-08 09:08:48 瀏覽:653
linux下ntp伺服器搭建 發布:2024-09-08 08:26:46 瀏覽:744
db2新建資料庫 發布:2024-09-08 08:10:19 瀏覽:173
頻率計源碼 發布:2024-09-08 07:40:26 瀏覽:780
奧迪a6哪個配置帶後排加熱 發布:2024-09-08 07:06:32 瀏覽:101
linux修改apache埠 發布:2024-09-08 07:05:49 瀏覽:209
有多少個不同的密碼子 發布:2024-09-08 07:00:46 瀏覽:566
linux搭建mysql伺服器配置 發布:2024-09-08 06:50:02 瀏覽:995