Re: [PHP] Re: Displaying images

2009-05-28 Thread kranthi
I suggest you use firebug
https://addons.mozilla.org/en-US/firefox/addon/1843

coming back to your case..
1. use the inspect function of firebug to check if the img src=.. is
displaying correctly.
2  then use the net tab of firebug to see if the image is actually
downloaded from the server.
3. open the link in new tab to see image is actually displayed.

if you are struck at case 1: some problem in the echo statement of your main
php
case 2: firebug actually tells you what is the mistake you did
case 3: i suggest one more firefox addon: live http headers
see if the content-type and content-length header are being sent


This page isn't working and if I try to browse this page it wants to open it
with an editor, it won't view in the browser.

i assume that the address in the URL bar of your browser starts with file://
rather than http:// ? simply put are you double clicking the file or
clicking open with firefox ?


Re: [PHP] Re: Displaying images

2009-05-28 Thread O. Lavell
Miller, Terion wrote:

[..]

 header(Content-type: img/jpeg);

[..]

 This page isn't working and if I try to browse this page it wants to
 open it with an editor, it won't view in the browser.
 
 What am I doing wrong? Is it the code or the data?

Content-type: img/jpeg is undefined, the browser would not know what to 
do with it. Try image/jpeg which is the official MIME type.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Displaying images

2009-05-28 Thread Miller, Terion



Well I have tried Numerous scripts and ways and still can't get the image to 
display.

I have echoed the file and have been able to get the gibberish image code to 
display but not a real image, here is my full code if anyone wants to have a 
look, I am going crossed eyed here.





These are just a few of the ways I have been trying to get the img tag to work 
on my output.php page:

   trtdScout Photo:/td  td  a 
href=image.php?filename=?php echo$row['photoName']; ??php 
echo$row['photoName']; ?/Abr?php echo 
\nbrScout Photo : .img src=\image.php?filename= .$row['photoName']. 
\; ?  ?php echo img 
src=\image.php?filename=.$row['photoName'].\\n; ?
?php echo img src=\image.php?id=.$row['ePID'].\\n; ?  
  img src=image2.php?filename=?php echo $row['photoName']; ?


Here is one way I was trying to get to work for the image.php page where the 
headers are supposed to work and don't

include(inc/dbconn_open.php);
error_reporting(E_ALL);


//if (isset($_FILES['ePhoto'])){$ePhoto = $_FILES['ePhoto'];} else {$ePhoto 
=;}

$filename = $_GET['$filename'];

$image = stripslashes($_REQUEST[photoName]);

$sql = SELECT ePhoto, photoName, photoType from eagleProjects WHERE photoName 
= $filename;
$result=mysql_query($sql);
$data = mysql_fetch_array ($result);



$type = $data['photoType'];
$name = $data['photoName'];

  header(Content-type: $type);
  header(Content-Disposition: attachment; filename=$name);


echo $data[photoName];
echo $data[ePhoto];

exit;

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Displaying images

2009-05-27 Thread Bastien Koert
On Wed, May 27, 2009 at 1:46 PM, Shawn McKenzie nos...@mckenzies.netwrote:

 Miller, Terion wrote:
  I am trying to get an image to display but I get nothing if done like
 this:
 
 tr
  tdScout Photo:/td
 
 tdimg src=?php echo $row['ePhoto'];?/td
 
  /tr
 
 
  If I just echo the field I do get the file name
 

 Does the filename include the path?  Does the image with said filename
 actually exist in that path?

 --
 Thanks!
 -Shawn
 http://www.spidean.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


Is it an image from the db or a path to an image on the filesystem?

-- 

Bastien

Cat, the other other white meat


Re: [PHP] Re: Displaying images

2009-05-27 Thread Miller, Terion



On 5/27/09 12:49 PM, Bastien Koert phps...@gmail.com wrote:

On Wed, May 27, 2009 at 1:46 PM, Shawn McKenzie nos...@mckenzies.netwrote:

 Miller, Terion wrote:
  I am trying to get an image to display but I get nothing if done like
 this:
 
 tr
  tdScout Photo:/td
 
 tdimg src=?php echo $row['ePhoto'];?/td
 
  /tr
 
 
  If I just echo the field I do get the file name
 

 Does the filename include the path?  Does the image with said filename
 actually exist in that path?

 --
 Thanks!
 -Shawn
 http://www.spidean.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


Is it an image from the db or a path to an image on the filesystem?

--

Bastien

Cat, the other other white meat


Hi Bastien it is an image in the db.
Thanks
Terion

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Displaying images

2009-05-27 Thread Bastien Koert
On Wed, May 27, 2009 at 1:51 PM, Miller, Terion 
tmil...@springfi.gannett.com wrote:




 On 5/27/09 12:49 PM, Bastien Koert phps...@gmail.com wrote:

 On Wed, May 27, 2009 at 1:46 PM, Shawn McKenzie nos...@mckenzies.net
 wrote:

  Miller, Terion wrote:
   I am trying to get an image to display but I get nothing if done like
  this:
  
  tr
   tdScout Photo:/td
  
  tdimg src=?php echo $row['ePhoto'];?/td
  
   /tr
  
  
   If I just echo the field I do get the file name
  
 
  Does the filename include the path?  Does the image with said filename
  actually exist in that path?
 
  --
  Thanks!
  -Shawn
  http://www.spidean.com
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 Is it an image from the db or a path to an image on the filesystem?

 --

 Bastien

 Cat, the other other white meat


 Hi Bastien it is an image in the db.
 Thanks
 Terion


You can't display the image that way due to differeing headers in required
for html and images. Change your image code to call a page that specializes
in handling the images and the headers needed by changing to something like
this:

echo img src=\show_image.php?id=.$rows['id'].\\n;

where the show_image page calls the image out from the db and display it as
below

?php
require(conn.php);
//check to see if the id is passed
if(isset($_GET['id'])) {
$id=$_GET['id'];

//query the database to get the image and the filetype
$query = select bin_data, filetype from binary_data where id=$id;

$result = mysql_query($query);
$row = mysql_fetch_array($result);
  {
   $data = $row['bin_data'];
   $type = $row['filetype'];
  }
  if ($type==pjpeg) $type = jpeg;   //handle the ms jpeg alternate
format
  Header( Content-type: $type);
  echo $data;
}
?
-- 

Bastien

Cat, the other other white meat


Re: [PHP] Re: Displaying images

2009-05-27 Thread Shawn McKenzie


Miller, Terion wrote:



 Does the filename include the path?  Does the image with said filename
 actually exist in that path?

 --
 Thanks!
 -Shawn
 http://www.spidean.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



 Hmm guess I am confused because the image is being stored in the db.
 So I thought I could call it like any other field data.

 Thanks
 Terion

   
Please reply all.

The img tag is used to tell the browser where the image is located, it
then loads the image.  If you have the binary image data in the DB then
you probably need to have a PHP file with a get var as the img src and
then have that PHP file actually output the image data:

img src=path/to/image.php?filename=?php echo $row['filename']; ?


//image.php
header(Content-type: img/jpeg);
$filename = $_GET['filename'];
//do your SQL select and fetch using filename or whatnot to get the
image data, I assume from 'ePhoto'
echo $row['ePhoto'];

Thanks!
-Shawn

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Displaying images

2009-05-27 Thread Ashley Sheridan
On Wed, 2009-05-27 at 14:03 -0400, Bastien Koert wrote:
 On Wed, May 27, 2009 at 1:51 PM, Miller, Terion 
 tmil...@springfi.gannett.com wrote:
 
 
 
 
  On 5/27/09 12:49 PM, Bastien Koert phps...@gmail.com wrote:
 
  On Wed, May 27, 2009 at 1:46 PM, Shawn McKenzie nos...@mckenzies.net
  wrote:
 
   Miller, Terion wrote:
I am trying to get an image to display but I get nothing if done like
   this:
   
   tr
tdScout Photo:/td
   
   tdimg src=?php echo $row['ePhoto'];?/td
   
/tr
   
   
If I just echo the field I do get the file name
   
  
   Does the filename include the path?  Does the image with said filename
   actually exist in that path?
  
   --
   Thanks!
   -Shawn
   http://www.spidean.com
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
  Is it an image from the db or a path to an image on the filesystem?
 
  --
 
  Bastien
 
  Cat, the other other white meat
 
 
  Hi Bastien it is an image in the db.
  Thanks
  Terion
 
 
 You can't display the image that way due to differeing headers in required
 for html and images. Change your image code to call a page that specializes
 in handling the images and the headers needed by changing to something like
 this:
 
 echo img src=\show_image.php?id=.$rows['id'].\\n;
 
 where the show_image page calls the image out from the db and display it as
 below
 
 ?php
 require(conn.php);
 //check to see if the id is passed
 if(isset($_GET['id'])) {
 $id=$_GET['id'];
 
 //query the database to get the image and the filetype
 $query = select bin_data, filetype from binary_data where id=$id;
 
 $result = mysql_query($query);
 $row = mysql_fetch_array($result);
   {
$data = $row['bin_data'];
$type = $row['filetype'];
   }
   if ($type==pjpeg) $type = jpeg;   //handle the ms jpeg alternate
 format
   Header( Content-type: $type);
   echo $data;
 }
 ?
That's only true if the image is stored in the database as a BLOB or
somesuch. If the database is just storing the filename of the image,
then it may just need the correct directory path prefix. Go into your
browser, right-click and check to see what path and filename the browser
expects to find the image file. My guess is it's not the same as where
the image actually is, and you need to add the path before opening the
?php tag. You can use either an absolute path (e.g. using a full
http://domain) or a relative one, and relative paths can include the ../
directory if you need to move up the directory tree.


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Displaying images

2009-05-27 Thread Bastien Koert
On Wed, May 27, 2009 at 3:05 PM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:

 On Wed, 2009-05-27 at 14:03 -0400, Bastien Koert wrote:
  On Wed, May 27, 2009 at 1:51 PM, Miller, Terion 
  tmil...@springfi.gannett.com wrote:
 
  
  
  
   On 5/27/09 12:49 PM, Bastien Koert phps...@gmail.com wrote:
  
   On Wed, May 27, 2009 at 1:46 PM, Shawn McKenzie nos...@mckenzies.net
   wrote:
  
Miller, Terion wrote:
 I am trying to get an image to display but I get nothing if done
 like
this:

tr
 tdScout Photo:/td

tdimg src=?php echo $row['ePhoto'];?/td

 /tr


 If I just echo the field I do get the file name

   
Does the filename include the path?  Does the image with said
 filename
actually exist in that path?
   
--
Thanks!
-Shawn
http://www.spidean.com
   
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
   
   
   Is it an image from the db or a path to an image on the filesystem?
  
   --
  
   Bastien
  
   Cat, the other other white meat
  
  
   Hi Bastien it is an image in the db.
   Thanks
   Terion
  
 
  You can't display the image that way due to differeing headers in
 required
  for html and images. Change your image code to call a page that
 specializes
  in handling the images and the headers needed by changing to something
 like
  this:
 
  echo img src=\show_image.php?id=.$rows['id'].\\n;
 
  where the show_image page calls the image out from the db and display it
 as
  below
 
  ?php
  require(conn.php);
  //check to see if the id is passed
  if(isset($_GET['id'])) {
  $id=$_GET['id'];
 
  //query the database to get the image and the filetype
  $query = select bin_data, filetype from binary_data where id=$id;
 
  $result = mysql_query($query);
  $row = mysql_fetch_array($result);
{
 $data = $row['bin_data'];
 $type = $row['filetype'];
}
if ($type==pjpeg) $type = jpeg;   //handle the ms jpeg
 alternate
  format
Header( Content-type: $type);
echo $data;
  }
  ?
 That's only true if the image is stored in the database as a BLOB or
 somesuch. If the database is just storing the filename of the image,
 then it may just need the correct directory path prefix. Go into your
 browser, right-click and check to see what path and filename the browser
 expects to find the image file. My guess is it's not the same as where
 the image actually is, and you need to add the path before opening the
 ?php tag. You can use either an absolute path (e.g. using a full
 http://domain) or a relative one, and relative paths can include the ../
 directory if you need to move up the directory tree.


 Ash
 www.ashleysheridan.co.uk


Terion stated it was in the db

-- 

Bastien

Cat, the other other white meat


Re: [PHP] Re: Displaying images

2009-05-27 Thread Ashley Sheridan
On Wed, 2009-05-27 at 15:14 -0400, Bastien Koert wrote:
 On Wed, May 27, 2009 at 3:05 PM, Ashley Sheridan
 a...@ashleysheridan.co.ukwrote:
 
  On Wed, 2009-05-27 at 14:03 -0400, Bastien Koert wrote:
   On Wed, May 27, 2009 at 1:51 PM, Miller, Terion 
   tmil...@springfi.gannett.com wrote:
  
   
   
   
On 5/27/09 12:49 PM, Bastien Koert phps...@gmail.com wrote:
   
On Wed, May 27, 2009 at 1:46 PM, Shawn McKenzie nos...@mckenzies.net
wrote:
   
 Miller, Terion wrote:
  I am trying to get an image to display but I get nothing if done
  like
 this:
 
 tr
  tdScout Photo:/td
 
 tdimg src=?php echo $row['ePhoto'];?/td
 
  /tr
 
 
  If I just echo the field I do get the file name
 

 Does the filename include the path?  Does the image with said
  filename
 actually exist in that path?

 --
 Thanks!
 -Shawn
 http://www.spidean.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


Is it an image from the db or a path to an image on the filesystem?
   
--
   
Bastien
   
Cat, the other other white meat
   
   
Hi Bastien it is an image in the db.
Thanks
Terion
   
  
   You can't display the image that way due to differeing headers in
  required
   for html and images. Change your image code to call a page that
  specializes
   in handling the images and the headers needed by changing to something
  like
   this:
  
   echo img src=\show_image.php?id=.$rows['id'].\\n;
  
   where the show_image page calls the image out from the db and display it
  as
   below
  
   ?php
   require(conn.php);
   //check to see if the id is passed
   if(isset($_GET['id'])) {
   $id=$_GET['id'];
  
   //query the database to get the image and the filetype
   $query = select bin_data, filetype from binary_data where id=$id;
  
   $result = mysql_query($query);
   $row = mysql_fetch_array($result);
 {
  $data = $row['bin_data'];
  $type = $row['filetype'];
 }
 if ($type==pjpeg) $type = jpeg;   //handle the ms jpeg
  alternate
   format
 Header( Content-type: $type);
 echo $data;
   }
   ?
  That's only true if the image is stored in the database as a BLOB or
  somesuch. If the database is just storing the filename of the image,
  then it may just need the correct directory path prefix. Go into your
  browser, right-click and check to see what path and filename the browser
  expects to find the image file. My guess is it's not the same as where
  the image actually is, and you need to add the path before opening the
  ?php tag. You can use either an absolute path (e.g. using a full
  http://domain) or a relative one, and relative paths can include the ../
  directory if you need to move up the directory tree.
 
 
  Ash
  www.ashleysheridan.co.uk
 
 
 Terion stated it was in the db
 
The thread didn't follow on properly, my email client wasn't able to
join t by thread so I didn't see his message until after I'd replied,
sorry!


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Displaying images

2009-05-27 Thread Miller, Terion


Thanks for the suggestions everyone, I have this now, but still no image 
showing up

It is stored as a blob in the database.

on the output page I am calling it like this:

img src=image.php?filename=?php echo $row['ePhoto']; ?

Then on the image.php page I have this:

?php
include(inc/dbconn_open.php);
error_reporting(E_ALL);

//image.php
header(Content-type: img/jpeg);
$filename = $_GET['filename'];

$sql = SELECT ePhoto from eagleProjects WHERE $filename= ePhoto;
$result=mysql_query($sql);
$row = mysql_fetch_assoc ($result);



?

?php echo $row['ePhoto']; ?

This page isn't working and if I try to browse this page it wants to open it 
with an editor, it won't view in the browser.

What am I doing wrong? Is it the code or the data?

Thanks
Terion

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Displaying images

2009-05-27 Thread Shawn McKenzie
Miller, Terion wrote:
 
 Thanks for the suggestions everyone, I have this now, but still no image 
 showing up
 
 It is stored as a blob in the database.
 
 on the output page I am calling it like this:
 
 img src=image.php?filename=?php echo $row['ePhoto']; ?

I was assuming that ePhoto was the actual binary data?  If so then you
need something else here like id or something.  I just used filename as
an example.  If ePhoto is actually the filename then you are OK here,
but not below.

 
 Then on the image.php page I have this:
 
 ?php
 include(inc/dbconn_open.php);
 error_reporting(E_ALL);
 
 //image.php
 header(Content-type: img/jpeg);
 $filename = $_GET['filename'];
 
 $sql = SELECT ePhoto from eagleProjects WHERE $filename= ePhoto;

Ummm...  This can't work.  What is ePhoto???  The data or the filename?

 $result=mysql_query($sql);
 $row = mysql_fetch_assoc ($result);
 
 
 
 ?
 
 ?php echo $row['ePhoto']; ?
 
 This page isn't working and if I try to browse this page it wants to open it 
 with an editor, it won't view in the browser.
 
 What am I doing wrong? Is it the code or the data?
 
 Thanks
 Terion


-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Displaying images

2009-05-27 Thread Shawn McKenzie
Shawn McKenzie wrote:
 Miller, Terion wrote:
 Thanks for the suggestions everyone, I have this now, but still no image 
 showing up

 It is stored as a blob in the database.

 on the output page I am calling it like this:

 img src=image.php?filename=?php echo $row['ePhoto']; ?
 
 I was assuming that ePhoto was the actual binary data?  If so then you
 need something else here like id or something.  I just used filename as
 an example.  If ePhoto is actually the filename then you are OK here,
 but not below.
 
 Then on the image.php page I have this:

 ?php
 include(inc/dbconn_open.php);
 error_reporting(E_ALL);

 //image.php
 header(Content-type: img/jpeg);
 $filename = $_GET['filename'];

 $sql = SELECT ePhoto from eagleProjects WHERE $filename= ePhoto;
 
 Ummm...  This can't work.  What is ePhoto???  The data or the filename?
 
 $result=mysql_query($sql);
 $row = mysql_fetch_assoc ($result);



 ?

 ?php echo $row['ePhoto']; ?

 This page isn't working and if I try to browse this page it wants to open it 
 with an editor, it won't view in the browser.

 What am I doing wrong? Is it the code or the data?

 Thanks
 Terion
 
 

I don't know what your fields are, but if ePhoto is the BLOB, and you
have an id field, then try this (assuming that you have selected id in
your query and it is an integer):

img src=image.php?id=?php echo $row['id']; ?

//image.php
$id = (int)$_GET['id'];
$sql = SELECT ePhoto from eagleProjects WHERE id=$id;

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php