* -- Vfp8.0 and 9.0 * -- save 1. Use Filetostr () to convert the image file to character. 2. Use Strconv (character A, 13) to convert character A to character B encoded by base64. 3. Save character B to the Text field or Access remarks field of SQLServer. * -- Restore or display 1. Use Strconv (character B,
* -- Vfp8.0 and 9.0 * -- save 1. Use Filetostr () to convert the image file to character. 2. Use Strconv (character A, 13) to convert character A to character B encoded by base64. 3. Save character B to the Text field or Access remarks field of SQL Server. * -- Restore or display 1. Use Strconv (character B,
* -- Vfp8.0, 9.0
*--
Save
1. Set
Image
FileConvert Filetostr () to.
2. Use Strconv ("character A", 13) to convert character A to character B encoded by base64.
3. Convert character B
SaveTo SQL Server Text
Type
Field
OrAccess
Remarks
Field.
*--RestoreOrDisplay
1. Use Strconv ("character B", 14) to encode base64 dataRestoreIt is A non-encoded data character.
2. Use Strtofile () to convertImageFileOr override character A to the PictureVal attribute of the Image control.Display
*--ImageExample
*Save
LcTextString = Strconv (Filetostr ("path \ImageName A "), 13) & base64 encoded data,YesSet this data (lcTextString)Save
*Restore
= Strtofile (Strconv (lcTextString or tableField, 14), "path \ImageName B ") & Change charactersRestoreBase64 pre-encoding data,RestoreChengFile
Thisform. Image1.Picture = "path \ImageName B "& setRestoreAfterImageOverride the Picture attribute of the Image control
* Or
Thisform. Image1.PictureVal = Strconv (lcTextString, 14) & set the characterRestoreThe PictureVal attribute (VFP9.0) of the Image control is directly overwritten after base64 encoding)
* -- Note:
In additionYesPairImageFileIn additionOthersFileSuch as Word, text, Exe, audio, video, etc.FileYes,FileDo not be too large; otherwise, the speed will be slow.
*------------------
This method is also applicable to Memo in DBF tables.Field(Binary is recommended.RemarksField, NormalRemarksField, Will automatically change when the code page changes, will damageFieldContent, binaryRemarksFieldNo.
If dbf binary is used directlyRemarksFieldSaveAnyFileContent, thenYesDirectly use the Filetostr/Strtofile function, and do not need to be converted to base64 (SQL or Access needs to be converted to base64), because vfp does not have unicode function, all binaryFileFunctions can be processed by string functions .).
For the Memo of the DBF tableFieldDirectly use the followingRemarksFieldDedicated commands andYesSaveAndRestoreLargeFile(Note: No matter what database, it is not recommended that a large numberFileSaveTo the table), use the Filetostr/Strtofile functionFileThe size is limited.
*Save:
Append MemoFieldName FromFileName: Overwrite
*Restore:
Copy MemoFieldName To generateFileName
*------------------
We recommend that you use Blob instead of VFP9.0.TypeField(Corresponding to the Image or Text of SQL ServerType), ItYesStore anyType. In this way, you can directly use the PictureVal attribute of the Image control that comes with vfp without using ActiveX.DisplayBmp/gif/png/jpg/tifImage.
BlobTypeFieldIt is better than the above method, because the disadvantage of the previous method is that the data becomes larger after being converted to Base64, which is not conducive to network load.
As for BlobTypeFieldOfFileStorage andRestore
* Storage
Replace BlobFieldWith Filetostr ("D :\FileFull name ")
*Restore
= Strtofile (BlobField, "D :\FileFull name ")
Use commonFieldIt is an outdated technology and has many drawbacks, suchFieldThere is no absolutely reliable method for the image againSaveFor DisksFile.