Access the answers to your technology questions today.
Subscribe Now
30-day free trial. Register in 60 seconds.
What Makes Experts Exchange Unique?
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.
Try it out and discover for yourself.
Subscribe Now
30-day free trial. Register in 60 seconds.
Join the Community
Give a Little. Get a Lot.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Join the Community
by: minichickenPosted on 2005-09-22 at 11:33:03ID: 14939270
Hi
as referenced in http:Q_21205707.html
There are actually three popular ways of uploading images in MySQL or other DBs
1.) Hardest method. save the image in the database as type BLOB. Load the image file either from the upload, as normal, or from another disc location. Read the file into a variable using file_get_contents() or similar. You need to pay careful attention to the type of the file, either using $_FILE[whatever][type] which is e.g. "image/gif".
Now, when you output the file, send a header("Content-type: image/gif"); and then output the contents of the BLOB. It should work fine.
2.) Easier method. Just upload the file, save it to disk, but store the filename in the database.
3.) Easy, but not easiest method. Upload the file, save it to disk using a unique identifier as filename (i.e. the auto_increment column from mysql), then save the original filename in the mysql database.
I hope this help...