hi,
please can anyone tell me how can i store a file(ms word, .jpeg, .rtf, .bmp etc.) in MySql database using html form and php script.
how to store a file to mysql database using php script
Moderator: General Moderators
-
suhail_anwar_khan
- Forum Newbie
- Posts: 11
- Joined: Mon Jan 15, 2007 4:22 pm
how to store a file to mysql database using php script
Last edited by suhail_anwar_khan on Wed Jan 17, 2007 2:49 pm, edited 1 time in total.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
You want to store the file itself in MySQL? (This is rarely recommended.)
http://php.net/features.file-upload
http://php.net/features.file-upload
- aaronhall
- DevNet Resident
- Posts: 1040
- Joined: Tue Aug 13, 2002 5:10 pm
- Location: Back in Phoenix, missing the microbrews
- Contact:
It's generally better to store the files themselves in a folder, and place whatever file information you need in the database. Unless you need to store the files in the database, check out http://us3.php.net/features.file-upload
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
Use the filesystem if you can, storing the filename in the database. If you're worried about filename collisions use the md5() of the file as it's name in the filesystem.
Otherwise, you'll need to re-create a filesystem in PHP & MySQL. I've done it, but I don't recommend doing it.
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
I once had a file system running out of MySQL where all the files were stored in the database. The files were not that large though, but they were encrypted. It was easier to just grab them from the DB, decrypt them, and display, but then again this is before I fully grasped the built in file system functions.