Lia Nungaray
asked on
How to attach a word document to a mysql db
How can I attach a word document into a mysql db? I'm creating a small application which will track employee reviews. Currently, all reviews are done in MS Word. What I would like my application to do, is once generated a review record for a particular employee, that the user have the ability to upload a word document containing the employee review. Where will the document be stored? Is a link stored in the db which will point to the correct document?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Another clever method would be to open the file using file(), read it into a variable, base64_encode() the contents of the file, and store it in a TEXT field in the mysql_database. Then, whenever you select the field from the database, you can base64_decode() the file and take its decoded contents and write it to a .doc file using fopen() and fputs().
But just in case DB size is an issue (because it will grow very fast and even become fragmented so you have to optimize it well) you can store the document on the file system and then store the link to the document in the DB.