Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

everyone. I am trying to create a database on PHPMyAdmin in Apache, where the picture would be in a separate field. I know the MIME type would be either image/jpeg or image/png but I don't know what to set the Type as and I don't know how to insert pictures into any of the tables in the database. Could somebody please help with this problem? Any help would be much appreciated.

share|improve this question
1  
For many reasons, it's usually advisable to store the pictures on the normal filesystem and just store the location of that file in the database. –  EEAA Mar 21 '11 at 13:37
add comment

2 Answers

up vote 1 down vote accepted

You CAN store pictures in a database, but I highly recommend against it. I run a big image versioning/indexing system driven off a database, and the maintenance overhead is appalling. You'll be doing a lot of integrity checking.

If you don't need to track version changes, I'd highly recommend putting the images in the filesystem, and only storing location information in the database.

share|improve this answer
    
Thanks Santanicpuppy, I appreciate the advice. So if I wanted to display these images on a web page, would I just retrieve the filename of the image and use that in html code? And what would be the Type, MIME Type, and the browser transformation of the image filename field? –  Engprof Mar 21 '11 at 13:55
    
@engprof: I'd use "varchar"; you're limited to 255 characters, but that's plenty for rational file names, and the speed is much faster than for text-type objects. Then, yep, you just pull the name of the image (with the information for it's location in the file system), and put that in a regular image tag. If you're going to be storing 10's of thousands of images, it makes sense to set up a hierarchy of image directories, so that you don't run into issues with the directories getting too large. –  Satanicpuppy Mar 21 '11 at 14:22
    
Thanks Satanicpuppy, I really appreciate this. I'll definitely try this out and tell you how it goes. –  Engprof Mar 21 '11 at 14:54
add comment

To store images in a MySQL database, you need to save them as BLOBs.

share|improve this answer
    
Thanks, Kenny. I appreciate this answer. I'll try it out and see how it goes. –  Engprof Mar 21 '11 at 13:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.