View Full Version : help wanted with file upload..!!
12-19-2008, 10:51 PM
I am working in PHP/MySQL and wanted to upload a file to Mysql database. I am having these problems:
1. the .doc files are not getting uploaded to Mysql database.
2. how do you retrieve the file from the database in another PHP script?
Thanks in advance.
12-19-2008, 11:54 PM
You'll need to post your code...
12-20-2008, 02:11 AM
Code would definitely help.
Without it, I can still give you some pointers. First and foremost, you're database must be using a binary object type for its field of appropriate length. This will likely be a mediumblob field.
Next, the algorithm:
- open file.
- read file into binary string (php will use binary by default since pre-5.3 binary is not a cast type).
- write binary data to the database.
Read works about the opposite. Since you're dealing with .doc files, php cannot handle those for display. You simply query the database, pass the appropriate headers to force a download, and print the binary data thats been retrieved from the database.
You can actually store this as base64 encoded in a text type field instead of blob style, but that takes what.... 3 times as much data I believe it is.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.