Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding pics/files in table fields

Status
Not open for further replies.

rooship

IS-IT--Management
Jun 25, 2003
20
Hello,
I am trying to create a table that contains mainly pics (jpeg) and files (pdf,.doc) stored directly in the fields. I only wish to keep the database all by itself. How can I do this?
I would really appreciate if someone could please advise me on this topic.

Thanks a lot for all your help
 
First advice - don't do it! It's not very efficient (or 'safe') to store large files in binary Memo fields and it's even worse to store them in General fields. You are much better off keeping the files in a separate directory (maybe ZIPped up) and just have the database "point" to them.

Rick
 
Hi,
Thanks for replying!
I read few posts on this forum saying the same thing that you mentioned about not storing the object directly. I cant figure out why? Are there any major drawbacks besides efficiency?
I have about 200 records with each record having each about 10 entries, so it would be really hard to maintain a directory with almost 2000 entries. What would be the best option ?

Thanks

 
Keeping the files in their native format and pointing to them will give you the ability to access them now with your current FoxPro system, but it also gives you the flexibility to access them in the future with other applications and products. Who knows what the best product for the job will be five years from now. If you want or need to evolve to something else in the future you are not locking yourself into the current Fox format.

With a well planned structure for your data folders, 2000 items is not at all unmanageable. Since you can easily create folders within you application, and then build fully qualified path names to the documents, there is really no reason not to store them as separate files.

Ev
 
rooship,

I don't mind using Binary Memo fields for this sort of thing. I've provided some code below which might help you in your endeavors.

*!* To save the file do something like the following
*!* Assumes "MyTable" is name of your table and
*!* "FileData" is name of Binary Memo Field
*!* "FileName" should probably be C(254)
*!* Code is simplified, you'll need to add
*!* additional error handling and modify to
*!* suit your needs
LOCAL lcFile
lcFile = GETFILE()
IF !EMPTY(lcFile)
APPEND Blank IN "MyTable"
Append Memo MyTable.FileData From (lcFile) Overwrite
Replace MyTable.FileName WITH JUSTFNAME(lcFile)
ENDIF

********************************************************

*!* To extract the file from the
*!* Binary Memo field
*!* Modify and use to suit your needs
LOCAL lcFile
*!* lcFile = MyTable.FileName &&If you wanted the real name
lcFile = ADDBS(SYS(2023))+"_"+SUBSTR(SYS(2015), 4)+"." + JUSTEXT(MyTable.FileName) &&Temp file in temp directory
Copy Memo MyTable.FileData to (lcFile)

Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
Thanks for all your responses. The posts were very helpful, and I really appreciate it.

- Rooshi
 
Rooshi,
Just one addition, if you are going to use SlightHaze's approach, you might want to check the SET BLOCKSIZE Command in the Help file. Changing from the default of 64 characters can greatly reduce the total size of your Memo (.FPT) file and speed up storing and retrival of your image files.

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top