469,903 Members | 1,808 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

Storing images in mySQL

Is there a way to store images in a mySQL database? I was hoping to store
them in a table, then use php to call them from the database and display the
picture on a webpage.

Any help would be appreciated.
Jul 19 '05 #1
9 16802
Put the binary raw content of the image in a BLOB (or MEDIUMBLOB) field.
Then do a select to get the content of that field. Put that content in a
temporary file with a random filename. In the PHP page, make a reference to
this temporary image by outputting the HTML.

<img src="<?php echo $temporary_filename; ?>">

I think there are more fancy ways of doing this, but that should be working.

Good luck

Vincent Bouret

"Ash Christopher" <as************@newthink.net> wrote in message
news:UI***********************@news1.calgary.shaw. ca...
Is there a way to store images in a mySQL database? I was hoping to store
them in a table, then use php to call them from the database and display the picture on a webpage.

Any help would be appreciated.

Jul 19 '05 #2
Put the binary raw content of the image in a BLOB (or MEDIUMBLOB) field.
Then do a select to get the content of that field. Put that content in a
temporary file with a random filename. In the PHP page, make a reference to
this temporary image by outputting the HTML.

<img src="<?php echo $temporary_filename; ?>">

I think there are more fancy ways of doing this, but that should be working.

Good luck

Vincent Bouret

"Ash Christopher" <as************@newthink.net> wrote in message
news:UI***********************@news1.calgary.shaw. ca...
Is there a way to store images in a mySQL database? I was hoping to store
them in a table, then use php to call them from the database and display the picture on a webpage.

Any help would be appreciated.

Jul 19 '05 #3
Put the binary raw content of the image in a BLOB (or MEDIUMBLOB) field.
Then do a select to get the content of that field. Put that content in a
temporary file with a random filename. In the PHP page, make a reference to
this temporary image by outputting the HTML.

<img src="<?php echo $temporary_filename; ?>">

I think there are more fancy ways of doing this, but that should be working.

Good luck

Vincent Bouret

"Ash Christopher" <as************@newthink.net> wrote in message
news:UI***********************@news1.calgary.shaw. ca...
Is there a way to store images in a mySQL database? I was hoping to store
them in a table, then use php to call them from the database and display the picture on a webpage.

Any help would be appreciated.

Jul 19 '05 #4
There's a good tutorial at: http://codewalkers.com/tutorials/35/1.html

-JD
"Ash Christopher" <as************@newthink.net> wrote in message
news:UI***********************@news1.calgary.shaw. ca...
Is there a way to store images in a mySQL database? I was hoping to store
them in a table, then use php to call them from the database and display the picture on a webpage.

Any help would be appreciated.

Jul 19 '05 #5
There's a good tutorial at: http://codewalkers.com/tutorials/35/1.html

-JD
"Ash Christopher" <as************@newthink.net> wrote in message
news:UI***********************@news1.calgary.shaw. ca...
Is there a way to store images in a mySQL database? I was hoping to store
them in a table, then use php to call them from the database and display the picture on a webpage.

Any help would be appreciated.

Jul 19 '05 #6
There's a good tutorial at: http://codewalkers.com/tutorials/35/1.html

-JD
"Ash Christopher" <as************@newthink.net> wrote in message
news:UI***********************@news1.calgary.shaw. ca...
Is there a way to store images in a mySQL database? I was hoping to store
them in a table, then use php to call them from the database and display the picture on a webpage.

Any help would be appreciated.

Jul 19 '05 #7
I read that tutorial - I'm only getting the filename stored in the
table, not the actual image -

$php_SQL = "UPDATE photos SET photo1 = '".$php_image."'"." WHERE
member_name = '".$php_member_name)."'";

Is this correct or am I missing something???

Raph

On Sun, 17 Aug 2003 17:04:11 GMT, "Jamie Davison" <ja***@bardavon.org>
wrote:
There's a good tutorial at: http://codewalkers.com/tutorials/35/1.html

-JD
"Ash Christopher" <as************@newthink.net> wrote in message
news:UI***********************@news1.calgary.shaw .ca...
Is there a way to store images in a mySQL database? I was hoping to store
them in a table, then use php to call them from the database and display

the
picture on a webpage.

Any help would be appreciated.


Jul 19 '05 #8
I read that tutorial - I'm only getting the filename stored in the
table, not the actual image -

$php_SQL = "UPDATE photos SET photo1 = '".$php_image."'"." WHERE
member_name = '".$php_member_name)."'";

Is this correct or am I missing something???

Raph

On Sun, 17 Aug 2003 17:04:11 GMT, "Jamie Davison" <ja***@bardavon.org>
wrote:
There's a good tutorial at: http://codewalkers.com/tutorials/35/1.html

-JD
"Ash Christopher" <as************@newthink.net> wrote in message
news:UI***********************@news1.calgary.shaw .ca...
Is there a way to store images in a mySQL database? I was hoping to store
them in a table, then use php to call them from the database and display

the
picture on a webpage.

Any help would be appreciated.


Jul 19 '05 #9
I read that tutorial - I'm only getting the filename stored in the
table, not the actual image -

$php_SQL = "UPDATE photos SET photo1 = '".$php_image."'"." WHERE
member_name = '".$php_member_name)."'";

Is this correct or am I missing something???

Raph

On Sun, 17 Aug 2003 17:04:11 GMT, "Jamie Davison" <ja***@bardavon.org>
wrote:
There's a good tutorial at: http://codewalkers.com/tutorials/35/1.html

-JD
"Ash Christopher" <as************@newthink.net> wrote in message
news:UI***********************@news1.calgary.shaw .ca...
Is there a way to store images in a mySQL database? I was hoping to store
them in a table, then use php to call them from the database and display

the
picture on a webpage.

Any help would be appreciated.


Jul 19 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by dave | last post: by
reply views Thread by Eben Goodman | last post: by
reply views Thread by Ash Christopher | last post: by
7 posts views Thread by Benoit St-Jean | last post: by
6 posts views Thread by bissatch | last post: by
4 posts views Thread by Rednelle | last post: by
1 post views Thread by steelghost | last post: by
3 posts views Thread by Lucky_Syringe | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.