364,085 Members | 5234 Browsing Online
Community for Developers & IT Professionals
Bytes IT Community

Loading pictures in mysql

Shaun Campbell
P: n/a
Shaun Campbell
I know you're going to say search the mail archives, but I have and I can't
find an answer to my simple question of is there an SQL statement to load an
image in a .jpg file into a database table?

Also, I have read in lots of places that it's probably not a good idea to
store images in mysql but just store a pointer to the file. Is this the
accepted way of doing things with mysql?

Thanks

Shaun


Jul 19 '05 #1
Share this Question
Share on Google+
4 Replies


sales@nospammers-seiretto.com
P: n/a
sales@nospammers-seiretto.com
Shuan,

Probably best to just store the url
(ie. http://domain-name.comm/images/i1.jpg)
within your MySQL database then use PHP to create the image tag in
HTML.

It could be argued that by already accessing the database one should
pull the actual image from the same source but that would be dependant
upon the size of the image and the number of images being pulled from
the database.... ...if the images are large or many the end user could
experience a delay in the initial display of the page (especially on a
shared/busy server). No delay (or at least would not be hampered by
large data retrieval) would occur if only the url was stored within
the database.


Dave Walker

For PHP and MySQL demo try here:
http://www.thedemosite.co.uk -- hey its free.
Seiretto for Hosting Solutions that Work.
http://www.Seiretto.com



On Fri, 12 Sep 2003 10:32:18 +0100, "Shaun Campbell"
<shaun.campbell@virgin.net> wrote:
[color=blue]
>I know you're going to say search the mail archives, but I have and I can't
>find an answer to my simple question of is there an SQL statement to load an
>image in a .jpg file into a database table?
>
>Also, I have read in lots of places that it's probably not a good idea to
>store images in mysql but just store a pointer to the file. Is this the
>accepted way of doing things with mysql?
>
>Thanks
>
>Shaun
>
>[/color]


Dave Walker

For PHP and MySQL demo try here:
http://www.thedemosite.co.uk -- hey its free.
Seiretto for Hosting Solutions that Work.
http://www.Seiretto.com
Jul 19 '05 #2

sales@nospammers-seiretto.com
P: n/a
sales@nospammers-seiretto.com
Shuan,

Probably best to just store the url
(ie. http://domain-name.comm/images/i1.jpg)
within your MySQL database then use PHP to create the image tag in
HTML.

It could be argued that by already accessing the database one should
pull the actual image from the same source but that would be dependant
upon the size of the image and the number of images being pulled from
the database.... ...if the images are large or many the end user could
experience a delay in the initial display of the page (especially on a
shared/busy server). No delay (or at least would not be hampered by
large data retrieval) would occur if only the url was stored within
the database.


Dave Walker

For PHP and MySQL demo try here:
http://www.thedemosite.co.uk -- hey its free.
Seiretto for Hosting Solutions that Work.
http://www.Seiretto.com



On Fri, 12 Sep 2003 10:32:18 +0100, "Shaun Campbell"
<shaun.campbell@virgin.net> wrote:
[color=blue]
>I know you're going to say search the mail archives, but I have and I can't
>find an answer to my simple question of is there an SQL statement to load an
>image in a .jpg file into a database table?
>
>Also, I have read in lots of places that it's probably not a good idea to
>store images in mysql but just store a pointer to the file. Is this the
>accepted way of doing things with mysql?
>
>Thanks
>
>Shaun
>
>[/color]


Dave Walker

For PHP and MySQL demo try here:
http://www.thedemosite.co.uk -- hey its free.
Seiretto for Hosting Solutions that Work.
http://www.Seiretto.com
Jul 19 '05 #3

Missaka Wijekoon
P: n/a
Missaka Wijekoon


Shaun Campbell wrote:[color=blue]
> I know you're going to say search the mail archives, but I have and I can't
> find an answer to my simple question of is there an SQL statement to load an
> image in a .jpg file into a database table?[/color]

I do not believe so. You could store it as a blob but I do not recommend
it. The main purpose of the database is indexing and searching data.
[color=blue]
>
> Also, I have read in lots of places that it's probably not a good idea to
> store images in mysql but just store a pointer to the file. Is this the
> accepted way of doing things with mysql?[/color]

Yes. It is faster to access the image from the file system than it is
to get it through MySQL.
[color=blue]
>
> Thanks
>
> Shaun
>
>[/color]


--
================================================== ======================
Missaka Wijekoon (a.k.a. Misk) mwijekoon@villageEdocs.com
Sr. Software Engineer http://www.villageEdocs.com
VillageEdocs Tel: (714) 734-1030 x17
14471 Chambers Rd, Suite 105 Fax: (800) 238-3669
Tustin, CA 92780
================================================== ======================

Jul 19 '05 #4

Missaka Wijekoon
P: n/a
Missaka Wijekoon


Shaun Campbell wrote:[color=blue]
> I know you're going to say search the mail archives, but I have and I can't
> find an answer to my simple question of is there an SQL statement to load an
> image in a .jpg file into a database table?[/color]

I do not believe so. You could store it as a blob but I do not recommend
it. The main purpose of the database is indexing and searching data.
[color=blue]
>
> Also, I have read in lots of places that it's probably not a good idea to
> store images in mysql but just store a pointer to the file. Is this the
> accepted way of doing things with mysql?[/color]

Yes. It is faster to access the image from the file system than it is
to get it through MySQL.
[color=blue]
>
> Thanks
>
> Shaun
>
>[/color]


--
================================================== ======================
Missaka Wijekoon (a.k.a. Misk) mwijekoon@villageEdocs.com
Sr. Software Engineer http://www.villageEdocs.com
VillageEdocs Tel: (714) 734-1030 x17
14471 Chambers Rd, Suite 105 Fax: (800) 238-3669
Tustin, CA 92780
================================================== ======================

Jul 19 '05 #5

Post your reply

Help answer this question



Didn't find the answer to your MySQL Database question?

You can also browse similar questions: MySQL Database