Page 1 of 1
MySQL / PHP file upload?
Posted: Wed Mar 02, 2005 8:52 am
by drgnjucr
Hello,
I am looking for a way to sucessfully upload physical documents (to include MSWord,MSExcel,etc..) to a MySQL db.
I've read a bit, and executed some code to upload the file(s) however it dumps the content into a BLOB filed type in MySQL and the content is destroyed if it's not a plain text file.
What I'm trying to acomplish here is my own way of document management/sharing amoung different organizations in my company and allow a "one stop shop" for putting/retreiving all related documents to a specific project. Also with that, I'll store the las time the file was upload; by whom, etc.. as well as the last download time, etc...
Anyone know if this is possible?
Thank you very much!
Posted: Wed Mar 02, 2005 9:28 am
by feyd
if you want to store the physical file in mysql, it needs to be in a BLOB type.. either BLOB, MEDIUMBLOB, or LONGBLOB as these are designed for binary data. BLOB has a maximum size of 64K, MEDIUMBLOB holds 16M, and LONGBLOB holds 4GB.. choose your poison

Posted: Wed Mar 02, 2005 10:22 am
by drgnjucr
Hi, Thanks.
Do you know how I would insert the actual file into the mediumblob filed? Currently, it looks like I'm opening the file with "fopen()" and it's attempting to place the content into the field.. at least I think that's what it's doing.
Posted: Wed Mar 02, 2005 10:25 am
by feyd
file_get_contents() ... however, I would personally use a version control software

Posted: Wed Mar 02, 2005 10:49 am
by drgnjucr
I'm sorry to ask, but would you be able to help me with the syntax of the function?
Posted: Wed Mar 02, 2005 10:52 am
by drgnjucr
Well, sort of an example as to how I put the file into the db with that function.
Posted: Wed Mar 02, 2005 12:32 pm
by drgnjucr
Actually, the code I have does work, just not in FF. It works fine in IE. hmmm.
Posted: Wed Mar 02, 2005 1:35 pm
by John Cartwright
Please use the edit button..
and post your code..
Posted: Wed Mar 02, 2005 1:38 pm
by drgnjucr
Ok, so I've narrowed it down even more. It's just M$ files that are not working when downloaded from FF.
It seems like upload works in FF...not as good as in IE, but it seems to work.
I've tried text files, and zip files.. all work no problem with FF. Just excel, word seem to have issues.
The working code I used is here:
http://www.php-mysql-tutorial.com/php-mysql-upload.php
Anyone know how to fix this?
Posted: Wed Mar 02, 2005 1:49 pm
by drgnjucr
Well, with more testing.......
When the file file is uploaded with FF (a word, excel) and you attempt to download it with IE... the "FileType" is blank.. but it opens anyhow.
If you upload it with FF, and try to dl it with FF and you choose to "Save to Disk" FF does not know what type of file it is. If you manually choose excel, it opens.
If you choose to open with when you try to DL with FF it will have the default application there, like.. excel. If you open it, it will open.
If it's all done with IE, works like champ. If you upload it with IE, and download it anyway with FF, works like a champ.
Seems like a slight bug with FF ....
Posted: Wed Mar 02, 2005 3:13 pm
by feyd
it is not a bug in Firefox.. it's a problem of not knowing the proper content-type