Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Andrew Barber
3,865 PointsStoring an image in mySQL
Hi Guys,
The title says it all. What is the best way of storing an image or image url into a mysql database?
I'm looking to display the image within an iphone app which I am working on.
Thanks!
2 Answers

James Barnett
39,199 PointsThere's a datatype in SQL called a blob
that's what you want to use.

James Barnett
39,199 PointsAndrew B - There's a big difference between the 2. In one case you are storing the image somewhere like on a CDN maybe and you have a link in stored in a database. On the other hand you are storing the actual image in the database itself.
Andrew Barber
3,865 PointsAndrew Barber
3,865 PointsThanks for the reply James.
I wasnt too sure how to use it as I'm still learning about mySQL.
Someone told me that I could store the image URL as a varchar too, is this correct and is there much of a difference between the two types?
image_url
varchar(2083) COLLATE utf8_unicode_ci NOT NULLMany Thanks, Andrew