...

View Full Version : help wanted with file upload..!!



mwitu
12-19-2008, 09: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.

fl00d
12-19-2008, 10:54 PM
You'll need to post your code...

Fou-Lu
12-20-2008, 01: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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum