在資料庫里面保存圖片資訊jpg和bmp兩種格式,
1、怎么存放到資料庫
2、怎么把存到資料庫德圖片下載到本機
uj5u.com熱心網友回復:
1 updateblob2 selectblob
uj5u.com熱心網友回復:
2樓把資料讀到變數里面了,該怎么把圖片保存到本機?
uj5u.com熱心網友回復:
writefile!uj5u.com熱心網友回復:
在視窗上加一圖片控制元件然后
p_1.SetPicture(圖片變數)
uj5u.com熱心網友回復:
不好意思,錯看成顯示圖片了uj5u.com熱心網友回復:
用檔案函式fileopen、filewrite等,把存放圖片的blob變數寫成本地檔案即可。
uj5u.com熱心網友回復:
//產生圖片檔案string ls_filename
blob lb_b
long ll_flen
integer li_filenum,li_loops,li_newpos,i
long value
//首先判斷是否存在檔案名相同的檔案
if right(as_path,1)='\' then
ls_filename = as_path + as_filename
else
ls_filename = as_path + '\' + as_filename
end if
//如果有相同名字的檔案,則先洗掉
IF FileExists(ls_filename) THEN
FileDelete(ls_filename)
END IF
ll_flen = len(ab_pic)
li_FileNum = FileOpen(ls_filename, StreamMode!, Write!, Shared!, Replace!)
//確定寫入次數
IF ll_flen > 32765 THEN
IF Mod(ll_flen, 32765) = 0 THEN
li_loops = int(ll_flen/32765)
ELSE
li_loops = int(ll_flen/32765) + 1
END IF
ELSE
li_loops = 1
END IF
//寫入檔案
li_newpos = 1
FOR i = 1 to li_loops
lb_b = blobmid(ab_pic, (i - 1) * 32765 + 1, 32765)
value = FileWrite(li_FileNum, lb_b)
if value < 0 then
messagebox("錯誤","生成臨時檔案出錯。")
return
end if
NEXT
if FileClose(li_filenum) < 0 then
messagebox("錯誤","關閉檔案出錯。")
return
else
//顯示檔案
wf_showfile(ls_filename,as_filetype)
end if
uj5u.com熱心網友回復:
正解uj5u.com熱心網友回復:
blob ls_blob,tempbselectblob a5701 into :ls_blob from a57 where a0000=:rybh; //從資料庫里去保存的圖片
ll_filelength=len(ls_blob)
if ll_filelength>0 then
IF ll_filelength > 32765 THEN //圖片過大處理方法
IF Mod(ll_filelength, 32765) = 0 THEN
loops =ll_filelength/32765
ELSE
loops = (ll_filelength/32765) + 1
END IF
ELSE
loops = 1
END IF
li_FileNum2 = FileOpen( gs_path+ "temp.JPG", &
StreamMode!, Write!, Shared!, Replace!) //打開一個臨時圖片檔案。 li_FileNum2
FOR i = 1 to loops
if i = loops then
tempb = blobmid(ls_blob,(i - 1)*32766 + 1 )
else
tempb = blobmid(ls_blob,( i - 1)*32766 + 1,32766 )
end if
FileWrite(li_FileNum2,tempb) //把取出的圖片資料寫入到那個臨時圖片檔案
NEXT
ls_photo=ls_blob
P_1.setpicture(ls_photo) //控制元件顯示圖片
FileClose(li_FileNum2)
dw_2.object.p_zp.filename = gs_path+ 'temp.JPG'//資料窗顯示那個圖片
、//////////更新圖片到資料庫
首先你表里要有個欄位是image型別
string ls_pathname, ls_filename
integer li_value,li_FileNum,loops,li_FileNum2,i
long ll_fileLength,bytes_read,new_pos
blob b, tot_b
li_value = GetFileOpenName("選擇照片", &
+ ls_pathname, ls_filename, "jpg","Jpg Files (*.jpg),*.jpg")
IF li_value = 1 THEN
// Set a wait cursor
SetPointer(HourGlass!)
// Get the file length, and open the file
ll_fileLength= FileLength(ls_filename)
li_FileNum = FileOpen(ls_filename, &
StreamMode!, Read!, LockRead!)
// Determine how many times to call FileRead
IF ll_filelength > 32765 THEN
IF Mod(ll_filelength, 32765) = 0 THEN
loops =ll_filelength/32765
ELSE
loops = (ll_filelength/32765) + 1
END IF
ELSE
loops = 1
END IF
// Read the file
if loops >32 then
messagebox('提示','圖片不能大于1M,太大將影響上傳和下載速度!')
FileClose(li_FileNum)
return
end if
new_pos = 1
FOR i = 1 to loops
bytes_read = FileRead(li_FileNum, b)
tot_b = tot_b + b
NEXT
FileClose(li_FileNum)
ls_photo=tot_b
P_1.setpicture(ls_photo)
updatephotoflag = 1
FileWrite(li_FileNum2, gb_photo)
updateblob a57 set a5701 = :ls_photo where a0000=:ls_rybh ;
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/83897.html
標籤:腳本語言
下一篇:分布式事務管理器設計??
