PHP mySQL image blobs

This is a discussion on PHP mySQL image blobs within the PHP Language forums, part of the PHP Programming Forums category; Ummm...I'm a little stuck on how to approach the following.... I have a mySQL table holding images (fields ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-15-2003
Rob
 
Posts: n/a
Default PHP mySQL image blobs

Ummm...I'm a little stuck on how to approach the following....

I have a mySQL table holding images (fields are: data (blob), name (text),
type (text), size(text), desc (text) )

If I want to show the image on a page (they're all jpg's), how do I do I
implement this?

Uploading, downloading, text listing it is easy...I'm just wondering how I
SHOW it. :-)

I'm completely brain-frozen on this.



Thanks in advance,
Robert


Reply With Quote
  #2 (permalink)  
Old 09-16-2003
Dana
 
Posts: n/a
Default Re: PHP mySQL image blobs

Rob wrote:
> I have a mySQL table holding images (fields are: data (blob), name (text),
> type (text), size(text), desc (text) )
> If I want to show the image on a page (they're all jpg's), how do I do I
> implement this?


just print them:
header ("Content-type: image/jpeg");
$sql="select blobfield from table where ...";
$result=mysql_query($sql,$conn);
$img=mysql_fetch_row($result);
print $img[0];

Dana




Reply With Quote
  #3 (permalink)  
Old 09-16-2003
BKDotCom
 
Posts: n/a
Default Re: PHP mySQL image blobs

<?php
// perhaps called get_image.php...
// pass $_GET params to specify image or session vars... etc..
// instead of <IMG src="image.jpg"> it's <IMG
src="get_image.php?image=something"> or whatever
//... get the blob code....
header("Content-type: image/jpeg");
echo image blob;
exit;
?>

"Rob" <robertkaranfilian@sbcglobal.net> wrote in message news:<dKn9b.3003$351.2082@newssvr29.news.prodigy.c om>...
> Ummm...I'm a little stuck on how to approach the following....
>
> I have a mySQL table holding images (fields are: data (blob), name (text),
> type (text), size(text), desc (text) )
>
> If I want to show the image on a page (they're all jpg's), how do I do I
> implement this?
>
> Uploading, downloading, text listing it is easy...I'm just wondering how I
> SHOW it. :-)
>
> I'm completely brain-frozen on this.
>
>
>
> Thanks in advance,
> Robert

Reply With Quote
  #4 (permalink)  
Old 09-17-2003
paul brown
 
Posts: n/a
Default Re: PHP mySQL image blobs

Yes, but how would one do it in the context of surrounding it with an
html page, and not just the image itself?

paul
BKDotCom wrote:

> <?php
> // perhaps called get_image.php...
> // pass $_GET params to specify image or session vars... etc..
> // instead of <IMG src="image.jpg"> it's <IMG
> src="get_image.php?image=something"> or whatever
> //... get the blob code....
> header("Content-type: image/jpeg");
> echo image blob;
> exit;
> ?>
>
> "Rob" <robertkaranfilian@sbcglobal.net> wrote in message news:<dKn9b.3003$351.2082@newssvr29.news.prodigy.c om>...
>
>>Ummm...I'm a little stuck on how to approach the following....
>>
>>I have a mySQL table holding images (fields are: data (blob), name (text),
>>type (text), size(text), desc (text) )
>>
>>If I want to show the image on a page (they're all jpg's), how do I do I
>>implement this?
>>
>>Uploading, downloading, text listing it is easy...I'm just wondering how I
>>SHOW it. :-)
>>
>>I'm completely brain-frozen on this.
>>
>>
>>
>>Thanks in advance,
>>Robert


Reply With Quote
  #5 (permalink)  
Old 09-17-2003
BKDotCom
 
Posts: n/a
Default Re: PHP mySQL image blobs

?? this has been answered

<!-- surrounding html -->
<IMG src="image_getting_script.php?image=whatever">
<!-- and some more -->

are you concerned about having a "separate" script for the image
getting?
don't need a separate script... your page-generating script could only
output the image when given certain paramaters...


paul brown <paul@paulbrown.net> wrote in message news:<ZcO9b.478412$Ho3.80600@sccrnsc03>...
> Yes, but how would one do it in the context of surrounding it with an
> html page, and not just the image itself?
>
> paul
> BKDotCom wrote:
> > <?php
> > // perhaps called get_image.php...
> > // pass $_GET params to specify image or session vars... etc..
> > // instead of <IMG src="image.jpg"> it's <IMG
> > src="get_image.php?image=something"> or whatever
> > //... get the blob code....
> > header("Content-type: image/jpeg");
> > echo image blob;
> > exit;
> > ?>
> >
> > "Rob" <robertkaranfilian@sbcglobal.net> wrote in message news:<dKn9b.3003$351.2082@newssvr29.news.prodigy.c om>...
> >
> >>Ummm...I'm a little stuck on how to approach the following....
> >>
> >>I have a mySQL table holding images (fields are: data (blob), name (text),
> >>type (text), size(text), desc (text) )
> >>
> >>If I want to show the image on a page (they're all jpg's), how do I do I
> >>implement this?
> >>
> >>Uploading, downloading, text listing it is easy...I'm just wondering how I
> >>SHOW it. :-)
> >>
> >>I'm completely brain-frozen on this.
> >>
> >>
> >>
> >>Thanks in advance,
> >>Robert

Reply With Quote
  #6 (permalink)  
Old 09-18-2003
Zac Hester
 
Posts: n/a
Default Re: PHP mySQL image blobs

paul brown wrote:

> Yes, but how would one do it in the context of surrounding it with an
> html page, and not just the image itself?
>
> paul
> BKDotCom wrote:
>
>> [snip: answer to question]
>>


BK answered your question (twice), but there's another possible answer
depending on your delivery context. If you're serving pages over WWW,
just use the "img" tag to point to your PHP script that prints the image
(like BK said). However, if you're using PHP to generate a MIME
encoded document (such as an email), you can also put the image data in
the HTML tag (so people aren't requesting a document on your server
every time they open that email message). If you are, in fact, creating
a MIME document, have a look at this article that has really good info
on MIME formats:

http://www.phpbuilder.com/columns/kartic20000807.php3

HTH,
Zac

Reply With Quote
  #7 (permalink)  
Old 09-18-2003
Rob
 
Posts: n/a
Default Re: PHP mySQL image blobs

Thanks Zac!

Actually, thank you everyone. Just for reference, phpbuilder has another
article for showing images directly from a db, including the PHP scripts...

http://www.phpbuilder.com/columns/fl...14.php3?page=1

But the MIME one you showed was also useful (for another project)


Robert



"Zac Hester" <news@planetzac.net> wrote in message
news:3f68dad4$1@news.enetis.net...
> paul brown wrote:
>
> > Yes, but how would one do it in the context of surrounding it with an
> > html page, and not just the image itself?
> >
> > paul
> > BKDotCom wrote:
> >
> >> [snip: answer to question]
> >>

>
> BK answered your question (twice), but there's another possible answer
> depending on your delivery context. If you're serving pages over WWW,
> just use the "img" tag to point to your PHP script that prints the image
> (like BK said). However, if you're using PHP to generate a MIME
> encoded document (such as an email), you can also put the image data in
> the HTML tag (so people aren't requesting a document on your server
> every time they open that email message). If you are, in fact, creating
> a MIME document, have a look at this article that has really good info
> on MIME formats:
>
> http://www.phpbuilder.com/columns/kartic20000807.php3
>
> HTH,
> Zac
>



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:24 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0