Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

macmanmatty

macrumors regular
Original poster
Jul 10, 2005
237
0
(x,y)
I know I can insert images into a mysql database, but is this reccommened for websites with lot of large pictures being stored in the database? How fast will it be?? Will any hosting services allow this?? Or should I just learn how to use a file system?


macmanmatty
 
You can include your images in your MySQL db, but it will quickly eat up disk space. A smarter thing to do would be to store the images in a folder and reference them in the db by name. Then when you are listing the image on your site you list the path to your images folder and then dynamically pull in the image name(s). I do it that way all the time and it works great.
 
You can include your images in your MySQL db, but it will quickly eat up disk space. A smarter thing to do would be to store the images in a folder and reference them in the db by name. Then when you are listing the image on your site you list the path to your images folder and then dynamically pull in the image name(s). I do it that way all the time and it works great.

ditto, brotha
 
You can include your images in your MySQL db, but it will quickly eat up disk space. A smarter thing to do would be to store the images in a folder and reference them in the db by name. Then when you are listing the image on your site you list the path to your images folder and then dynamically pull in the image name(s). I do it that way all the time and it works great.

Why do the images take up more space in the database than they would sitting in a folder? Surely a 36KB jpg (example) is a 36KB jpg.

Can you explain as I am genuinely curious. Is it something to do with the way they are stored?
 
Why do the images take up more space in the database than they would sitting in a folder? Surely a 36KB jpg (example) is a 36KB jpg.

Can you explain as I am genuinely curious. Is it something to do with the way they are stored?

He isn't saying it will eat up more, but rather the actual database size will be much larger. (to be honest I bet if you totaled up the bytes from the image reference column plus the file and compared it with a pointer reference and a blob field that held a image, the former would end up being larger)

While I agree with using references to retrieve the file it i theory it would be faster to add a blob field and store your images in it and then retrieve with a pointer, but unless you are doing in house production with still multi-MB files (like ILM uses) you aren't really going to see any difference. Further your host would probably frown with you using up database space and ram when images were retrieved from the database. Last over the web it won't make a difference since the bottlenecks are usually not hosts but rather client connections.

Anyway... I do agree with Stampyhead that is nearly all web based galleries do it.
 
THnaks for all the replys I guess I will just store the images on the server and reference them in the database. seems to be the best way to go.

macmanmatty
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.