Home > database >  The binary image data
The binary image data

Time:09-27

Save the file in database information JPG, BMP formats,

1, how to store the database

2, how to save to the database, images are downloaded to the machine

CodePudding user response:

1 updateblob
2 selectblob

CodePudding user response:

The second floor

Read data into the variable, how to save the image to the machine?

CodePudding user response:

Writefile!

CodePudding user response:

Plus one picture on window controls

Then
P_1. SetPicture (image variables)

CodePudding user response:

Sorry, the wrong as display images

CodePudding user response:

refer to the second floor ztao1212 response:

2 floor
Read data into the variable, how to save the image to the machine?


Using file function fileopen filewrite etc., to local files can be written the stored image blob variable,

CodePudding user response:

//generated image file
String ls_filename
Blob lb_b
Long ll_flen
Integer li_filenum, li_loops li_newpos, I
Long value

//first determines whether there is a file of the same file
If right (as_path, 1)='\' then
Ls_filename=as_path + as_filename
The else
Ls_filename=as_path + '\' + as_filename
End the if

//if you have the same name of the file, the first remove
IF FileExists (ls_filename) THEN
FileDelete (ls_filename)
END the IF

Ll_flen=len (ab_pic)
Li_FileNum=FileOpen (ls_filename StreamMode! The Write! , Shared! The Replace!
//sure write number
IF ll_flen & gt; THEN 32765
IF the Mod (ll_flen, 32765)=0 THEN
Li_loops=int (ll_flen/32765)
The ELSE
Li_loops=int (ll_flen/32765) + 1
END the IF
The ELSE
Li_loops=1
END the IF
//write file
Li_newpos=1
FOR I=1 to li_loops
Lb_b=blobmid (ab_pic, (I - 1) * 32765 + 1, 32765)
Value=https://bbs.csdn.net/topics/FileWrite (li_FileNum lb_b)
If the value & lt; 0 then
Messagebox (" error ", "error to generate temporary files,")
Return
End the if
NEXT
If FileClose (li_filenum) & lt; 0 then
Messagebox (" error ", "close the file error,")
Return
The else
//display file
Wf_showfile (ls_filename as_filetype)
end if

CodePudding user response:

Positive solution
refer to 7th floor awang_126 response:
//generated image file
String ls_filename
Blob lb_b
Long ll_flen
Integer li_filenum, li_loops li_newpos, I
Long value

//first determines whether there is a file of the same file
If right (as_path, 1)='\' then
Ls_filename=as_path + as_filename
Els...

CodePudding user response:

Blob ls_blob, tempb
Selectblob a5701 into: ls_blob from a57 where a0000=: rybh;//to save images from the database

Ll_filelength=len (ls_blob)
If ll_filelength & gt; 0 then
IF ll_filelength & gt; 32765 too much THEN//image processing method
IF the Mod (ll_filelength, 32765)=0 THEN
Loops=ll_filelength/32765
The ELSE
Loops=(ll_filelength/32765) + 1
END the IF
The ELSE
Loops=1
END the IF


Li_FileNum2=FileOpen (gs_path + "temp. JPG", & amp;
StreamMode! The Write! , Shared! The Replace!//open a temporary file images, li_FileNum2

FOR I=1 to loops
If I=loops then
Tempb=blobmid (ls_blob, (I - 1) * 32766 + 1)
The else
Tempb=blobmid (ls_blob, (I - 1) * 32766 + 1327 66)
End the if
FileWrite (li_FileNum2 tempb)//out of the image data written to the temporary file
NEXT

Ls_photo=ls_blob
P_1. Setpicture (ls_photo)//control display images
FileClose (li_FileNum2)
Dw_2. Object. P_zp. Filename=gs_path + 'temp. JPG'//data window shows the picture


,//////////photos to update database
Table you want to have a field is the first image type
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=https://bbs.csdn.net/topics/GetFileOpenName (" choose photo ", & amp;
+ ls_pathname ls_filename, "JPG", "JPG Files (*.jpg), *. JPG")
IF li_value=https://bbs.csdn.net/topics/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, & amp;
StreamMode! , Read! , LockRead!)
//Determine how many times to call FileRead
IF ll_filelength & gt; THEN 32765
IF the Mod (ll_filelength, 32765)=0 THEN
Loops=ll_filelength/32765
The ELSE
Loops=(ll_filelength/32765) + 1
END the IF
The ELSE
Loops=1
END the IF
//Read the file
If loops & gt; 32 then
Messagebox (' prompt ', 'the picture is not greater than 1 m, too big impact to upload and download speed! ')
FileClose (li_FileNum)
Return
End the 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;
  • Related