Re: [PHP] Unable to display images on browser

2002-03-01 Thread Andrew Brampton

RE: [PHP] Unable to display images on browserI've never done this in PHP, but one way 
of testing if your output is correct is telnet to your webserver and request the php 
script yourself. Then request a valid JPG (or whatever), and compare the outputs..

If you have netcat (great tool), you can do this:
nc localhost 80 -v >> output.txt
GET /ddownloadfile.php?fileId=1 HTTP/1.0

and in output.txt would be some headers and some raw data, and u can compare this to a 
normal jpg request.

If you don't have netcat, then just use standard telnet that comes with windows and 
type 
GET /ddownloadfile.php?fileId=1 HTTP/1.0
for the request as normal

Hope this helps
Andrew
  - Original Message - 
  From: Narvaez, Teresa 
  To: 'Andrew Brampton' ; [EMAIL PROTECTED] ; [EMAIL PROTECTED] 
  Sent: Friday, March 01, 2002 10:21 PM
  Subject: RE: [PHP] Unable to display images on browser


  Andrew, 
  That is exactly what I am trying to do but the only thing I get is a box 
with an X on IE 4.0 and Netscape Communicator 4.73.  Please see my a fragement of my 
php code below. Thanks in advance! -Teresa

  -- 
  file1.php 
  -- 
   
SOME_HTLM_CODE_TO_DISPLAY_DB_FIELDS_GOES_HERE; 
" > 
   Download Now 
   
  -- 
  ddownloadfile.php 
  -- 
  "; 
  if ( mysql_num_rows($result) == 1) 
  { 
$fileType = @mysql_result($result,0, "type"); 
$fileContent = @mysql_result($result, 0, "Image"); 
$filedesc = @mysql_result($result,0, "description"); 
$filenum = @mysql_result($result,0, "PicNum"); 
  // Header("Content-type: image/gif"); 
Header("Content-type: $fileType"); 
echo $fileContent; 
  } 
  else 
  { 
echo "Record does not exist"; 
  } // else 

  ?> 
  -Original Message- 
  From: Andrew Brampton [mailto:[EMAIL PROTECTED]] 
  Sent: Friday, March 01, 2002 5:08 PM 
  To: Narvaez, Teresa; [EMAIL PROTECTED]; 
  [EMAIL PROTECTED] 
  Subject: Re: [PHP] Unable to display images on browser 



  if u have the data stored in the DB, just chuck the data out, with the 
  correct mime-type header.. 

  Andrew 



  -- 



  - Original Message - 
  From: "Narvaez, Teresa" <[EMAIL PROTECTED]> 
  To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> 
  Sent: Friday, March 01, 2002 8:41 PM 
  Subject: RE: [PHP] Unable to display images on browser 



  > Hello, 
  > Thanks for your responses; however, I do not think I have the gd 
  > libraries installed because ImageCreateFromString() was not found.  I will 
  > install it. 
  > 
  > I have a question: I can display the PNG or GIF image using the 
  > browser.  So Why do I need the GD library?  Since I store the mime type in 
  > the database I think that a call to header() to tell the browser what type 
  > of mime-type is coming from the database should sufice.  Also, I want to 
  > store any type of binary data into my database (PNG, GIF, word, JPG, etc) 
  Am 
  > I missing something? 
  > 
  > Thanks, 
  > -Teresa 
  > 
  > 
  > -Original Message- 
  > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
  > Sent: Thursday, February 28, 2002 4:12 AM 
  > To: [EMAIL PROTECTED] 
  > Subject: RE: [PHP] Unable to display images on browser 
  > 
  > 
  > You need to insert the following lines after this line: 
  > Header("Content-type: image/gif"); 
  > 
  > $im = ImageCreateFromString ($fileContent); 
  > ImageGif ($im); 
  > 
  > and then remove this line: echo $fileContent; 
  > That should do it. 
  > 
  > /Joakim 
  > 
  > -Original Message- 
  > From: Narvaez, Teresa [mailto:[EMAIL PROTECTED]] 
  > Sent: Wednesday, February 27, 2002 8:32 PM 
  > To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED] 
  > Subject: RE: [PHP] Unable to display images on browser 
  > 
  > 
  > Hello, Thanks for your help.  This is what I have for file1.php and 
  > ddownloadfile.php.  What I want is to click on "Donwnload now" link and be 
  > able to get the file out of the database and display it on the browser. 
  > Thank you in adavance, -Teresa 
  > file1.php 
  > --- 
  > while ($row = mysql_fetch_array($result)) 
  >{ 
  > ?> 
  >   SOME_HTLM_CODE_TO_DISPLAY_DB_FIELDS_GOES_HERE; 
  > //  \" 
  > > 
  >   " > 
  >  Download Now 
  >
  >
  >
  >  
  > 
  > ddownloadfile.php 
  > -- 
  >  $dbQuery = "Select PicNum, size, type, description, Image"; 
  > $dbQuery .= " FROM Images WHERE PicNum =

RE: [PHP] Unable to display images on browser

2002-03-01 Thread Narvaez, Teresa

Andrew,
That is exactly what I am trying to do but the only thing I get is a
box with an X on IE 4.0 and Netscape Communicator 4.73.  Please see my a
fragement of my php code below. Thanks in advance! -Teresa

--
file1.php
--

  SOME_HTLM_CODE_TO_DISPLAY_DB_FIELDS_GOES_HERE;
  " >
 Download Now

--
ddownloadfile.php
--
";
if ( mysql_num_rows($result) == 1)
{
  $fileType = @mysql_result($result,0, "type");
  $fileContent = @mysql_result($result, 0, "Image");
  $filedesc = @mysql_result($result,0, "description");
  $filenum = @mysql_result($result,0, "PicNum");
// Header("Content-type: image/gif");
  Header("Content-type: $fileType");
  echo $fileContent;
}
else
{
  echo "Record does not exist";
} // else

?>
-Original Message-
From: Andrew Brampton [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 01, 2002 5:08 PM
To: Narvaez, Teresa; [EMAIL PROTECTED];
[EMAIL PROTECTED]
Subject: Re: [PHP] Unable to display images on browser


if u have the data stored in the DB, just chuck the data out, with the
correct mime-type header..

Andrew


--


- Original Message -
From: "Narvaez, Teresa" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, March 01, 2002 8:41 PM
Subject: RE: [PHP] Unable to display images on browser


> Hello,
> Thanks for your responses; however, I do not think I have the gd
> libraries installed because ImageCreateFromString() was not found.  I will
> install it.
>
> I have a question: I can display the PNG or GIF image using the
> browser.  So Why do I need the GD library?  Since I store the mime type in
> the database I think that a call to header() to tell the browser what type
> of mime-type is coming from the database should sufice.  Also, I want to
> store any type of binary data into my database (PNG, GIF, word, JPG, etc)
Am
> I missing something?
>
> Thanks,
> -Teresa
>
>
> -----Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, February 28, 2002 4:12 AM
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP] Unable to display images on browser
>
>
> You need to insert the following lines after this line:
> Header("Content-type: image/gif");
>
> $im = ImageCreateFromString ($fileContent);
> ImageGif ($im);
>
> and then remove this line: echo $fileContent;
> That should do it.
>
> /Joakim
>
> -Original Message-
> From: Narvaez, Teresa [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 27, 2002 8:32 PM
> To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]
> Subject: RE: [PHP] Unable to display images on browser
>
>
> Hello, Thanks for your help.  This is what I have for file1.php and
> ddownloadfile.php.  What I want is to click on "Donwnload now" link and be
> able to get the file out of the database and display it on the browser.
> Thank you in adavance, -Teresa
> file1.php
> ---
> while ($row = mysql_fetch_array($result))
>{
> ?>
>   SOME_HTLM_CODE_TO_DISPLAY_DB_FIELDS_GOES_HERE;
> //  \"
> >
>   " >
>  Download Now
>   
>   
>   
> 
>
> ddownloadfile.php
> --
>  $dbQuery = "Select PicNum, size, type, description, Image";
> $dbQuery .= " FROM Images WHERE PicNum = $fileId";
> $result = mysql_query($dbQuery)
> or die ("Could not get file list: " . mysql_error() );
> echo "Sent Query successfully";
> if ( mysql_num_rows($result) == 1)
> {
> $fileType = @mysql_result($result,0, "type");
> $fileContent = @mysql_result($result, 0, "Image");
> $filedesc = @mysql_result($result,0, "description");
> $filenum = @mysql_result($result,0, "PicNum");
> Header("Content-type: image/gif");
> echo $fileContent;
> }
> else
> {
> echo "Record does not exist";
> } // else
> ?>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>



Re: [PHP] Unable to display images on browser

2002-03-01 Thread Andrew Brampton

if u have the data stored in the DB, just chuck the data out, with the
correct mime-type header..

Andrew
- Original Message -
From: "Narvaez, Teresa" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, March 01, 2002 8:41 PM
Subject: RE: [PHP] Unable to display images on browser


> Hello,
> Thanks for your responses; however, I do not think I have the gd
> libraries installed because ImageCreateFromString() was not found.  I will
> install it.
>
> I have a question: I can display the PNG or GIF image using the
> browser.  So Why do I need the GD library?  Since I store the mime type in
> the database I think that a call to header() to tell the browser what type
> of mime-type is coming from the database should sufice.  Also, I want to
> store any type of binary data into my database (PNG, GIF, word, JPG, etc)
Am
> I missing something?
>
> Thanks,
> -Teresa
>
>
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, February 28, 2002 4:12 AM
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP] Unable to display images on browser
>
>
> You need to insert the following lines after this line:
> Header("Content-type: image/gif");
>
> $im = ImageCreateFromString ($fileContent);
> ImageGif ($im);
>
> and then remove this line: echo $fileContent;
> That should do it.
>
> /Joakim
>
> -Original Message-
> From: Narvaez, Teresa [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 27, 2002 8:32 PM
> To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]
> Subject: RE: [PHP] Unable to display images on browser
>
>
> Hello, Thanks for your help.  This is what I have for file1.php and
> ddownloadfile.php.  What I want is to click on "Donwnload now" link and be
> able to get the file out of the database and display it on the browser.
> Thank you in adavance, -Teresa
> file1.php
> ---
> while ($row = mysql_fetch_array($result))
>{
> ?>
>   SOME_HTLM_CODE_TO_DISPLAY_DB_FIELDS_GOES_HERE;
> //  \"
> >
>   " >
>  Download Now
>   
>   
>   
> 
>
> ddownloadfile.php
> --
>  $dbQuery = "Select PicNum, size, type, description, Image";
> $dbQuery .= " FROM Images WHERE PicNum = $fileId";
> $result = mysql_query($dbQuery)
> or die ("Could not get file list: " . mysql_error() );
> echo "Sent Query successfully";
> if ( mysql_num_rows($result) == 1)
> {
> $fileType = @mysql_result($result,0, "type");
> $fileContent = @mysql_result($result, 0, "Image");
> $filedesc = @mysql_result($result,0, "description");
> $filenum = @mysql_result($result,0, "PicNum");
> Header("Content-type: image/gif");
> echo $fileContent;
> }
> else
> {
> echo "Record does not exist";
> } // else
> ?>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


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




RE: [PHP] Unable to display images on browser

2002-03-01 Thread Narvaez, Teresa

Hello, 
Thanks for your responses; however, I do not think I have the gd
libraries installed because ImageCreateFromString() was not found.  I will
install it. 

I have a question: I can display the PNG or GIF image using the
browser.  So Why do I need the GD library?  Since I store the mime type in
the database I think that a call to header() to tell the browser what type
of mime-type is coming from the database should sufice.  Also, I want to
store any type of binary data into my database (PNG, GIF, word, JPG, etc) Am
I missing something?  

Thanks, 
-Teresa


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 28, 2002 4:12 AM
To: [EMAIL PROTECTED]
Subject: RE: [PHP] Unable to display images on browser


You need to insert the following lines after this line:
Header("Content-type: image/gif");

$im = ImageCreateFromString ($fileContent); 
ImageGif ($im); 

and then remove this line: echo $fileContent;
That should do it.

/Joakim

-Original Message-
From: Narvaez, Teresa [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 27, 2002 8:32 PM
To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]
Subject: RE: [PHP] Unable to display images on browser


Hello, Thanks for your help.  This is what I have for file1.php and
ddownloadfile.php.  What I want is to click on "Donwnload now" link and be
able to get the file out of the database and display it on the browser.
Thank you in adavance, -Teresa
file1.php 
--- 
 
  SOME_HTLM_CODE_TO_DISPLAY_DB_FIELDS_GOES_HERE; 
//  \"
> 
  " > 
 Download Now 
   
   
   
"; 
if ( mysql_num_rows($result) == 1) 
{ 
$fileType = @mysql_result($result,0, "type"); 
$fileContent = @mysql_result($result, 0, "Image"); 
$filedesc = @mysql_result($result,0, "description"); 
$filenum = @mysql_result($result,0, "PicNum"); 
Header("Content-type: image/gif"); 
echo $fileContent; 
} 
else 
{ 
echo "Record does not exist"; 
} // else 
?> 

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



RE: [PHP] Unable to display images on browser

2002-02-28 Thread joakim . andersson

You need to insert the following lines after this line:
Header("Content-type: image/gif");

$im = ImageCreateFromString ($fileContent); 
ImageGif ($im); 

and then remove this line: echo $fileContent;
That should do it.

/Joakim

-Original Message-
From: Narvaez, Teresa [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 27, 2002 8:32 PM
To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]
Subject: RE: [PHP] Unable to display images on browser


Hello, Thanks for your help.  This is what I have for file1.php and
ddownloadfile.php.  What I want is to click on "Donwnload now" link and be
able to get the file out of the database and display it on the browser.
Thank you in adavance, -Teresa
file1.php 
--- 
 
  SOME_HTLM_CODE_TO_DISPLAY_DB_FIELDS_GOES_HERE; 
//  \"
> 
  " > 
 Download Now 
   
   
   
"; 
if ( mysql_num_rows($result) == 1) 
{ 
$fileType = @mysql_result($result,0, "type"); 
$fileContent = @mysql_result($result, 0, "Image"); 
$filedesc = @mysql_result($result,0, "description"); 
$filenum = @mysql_result($result,0, "PicNum"); 
Header("Content-type: image/gif"); 
echo $fileContent; 
} 
else 
{ 
echo "Record does not exist"; 
} // else 
?> 

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




RE: [PHP] Unable to display images on browser

2002-02-27 Thread Narvaez, Teresa

Hello, Thanks for your help.  This is what I have for file1.php and
ddownloadfile.php.  What I want is to click on "Donwnload now" link and be
able to get the file out of the database and display it on the browser.
Thank you in adavance, -Teresa

file1.php
---
 
  SOME_HTLM_CODE_TO_DISPLAY_DB_FIELDS_GOES_HERE; 

//  \"
>
  " >
 Download Now
  
  
  

";

if ( mysql_num_rows($result) == 1)
{
$fileType = @mysql_result($result,0, "type");
$fileContent = @mysql_result($result, 0, "Image");
$filedesc = @mysql_result($result,0, "description");
$filenum = @mysql_result($result,0, "PicNum");
Header("Content-type: image/gif");
echo $fileContent;
}
else
{
echo "Record does not exist";
} // else

?> 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 27, 2002 4:56 AM
To: [EMAIL PROTECTED]
Subject: RE: [PHP] Unable to display images on browser


Well, you probably need to do something like this:

file1.php (where you want to display an image)



end file1


getimage.php (the  
---end getimage.php

Good Luck
/Joakim


> -Original Message-
> From: Narvaez, Teresa [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 27, 2002 2:08 AM
> To: 'Dean Householder'; [EMAIL PROTECTED]
> Subject: [PHP] Unable to display images on browser
> 
> 
> Hello, 
>   I do not understand why I can't display images 
> retrieved from MySQL
> on my browser(IE 4.0).  When I retrieve the image from MYSQL I set the
> Header function to change the type of content(image/gif) I am 
> sending to the
> browser. However, the browser displays an box with an X in 
> it.  I would
> greatly appretiate any ideas/help.  Here is the piece of 
> code:  Thanks in
> advance! -Teresa
> 
>   Code to connect and selected DB not included
> -
> $dbQuery = "Select PicNum, size, type, description, Image";
> $dbQuery .= " FROM Images WHERE PicNum = $fileId";
> 
> $result = mysql_query($dbQuery)
> or die ("Could not get file list: " . mysql_error() );
> echo "Sent Query successfully";
> 
> if ( mysql_num_rows($result) == 1)
> {
> $fileType = @mysql_result($result,0, "type");
> $fileContent = @mysql_result($result, 0, "Image");
> $filedesc = @mysql_result($result,0, "description");
> $filenum = @mysql_result($result,0, "PicNum");
> //  Header("Content-type: $fileType"); 
> Header("Content-type: image/gif");
> echo $fileContent;
> }   
> else
> {
> echo "Record does not exist";
> } // else
> ?> 
> 

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



RE: [PHP] Unable to display images on browser

2002-02-27 Thread joakim . andersson

Well, you probably need to do something like this:

file1.php (where you want to display an image)



end file1


getimage.php (the  
---end getimage.php

Good Luck
/Joakim


> -Original Message-
> From: Narvaez, Teresa [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 27, 2002 2:08 AM
> To: 'Dean Householder'; [EMAIL PROTECTED]
> Subject: [PHP] Unable to display images on browser
> 
> 
> Hello, 
>   I do not understand why I can't display images 
> retrieved from MySQL
> on my browser(IE 4.0).  When I retrieve the image from MYSQL I set the
> Header function to change the type of content(image/gif) I am 
> sending to the
> browser. However, the browser displays an box with an X in 
> it.  I would
> greatly appretiate any ideas/help.  Here is the piece of 
> code:  Thanks in
> advance! -Teresa
> 
>   Code to connect and selected DB not included
> -
> $dbQuery = "Select PicNum, size, type, description, Image";
> $dbQuery .= " FROM Images WHERE PicNum = $fileId";
> 
> $result = mysql_query($dbQuery)
> or die ("Could not get file list: " . mysql_error() );
> echo "Sent Query successfully";
> 
> if ( mysql_num_rows($result) == 1)
> {
> $fileType = @mysql_result($result,0, "type");
> $fileContent = @mysql_result($result, 0, "Image");
> $filedesc = @mysql_result($result,0, "description");
> $filenum = @mysql_result($result,0, "PicNum");
> //  Header("Content-type: $fileType"); 
> Header("Content-type: image/gif");
> echo $fileContent;
> }   
> else
> {
> echo "Record does not exist";
> } // else
> ?> 
> 

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




Re: [PHP] Unable to display images on browser

2002-02-27 Thread Stewart G.

try using gd if you have >= 1.8.3 then you will have to use ImagePng() and 
Content-type: image/png instead of ImageGif() to export the image.

header ("Content-type: image/gif");
$im = ImageCreateFromString ($fileContent);
ImageGif ($im);

=S.

On Tue, 26 Feb 2002, Narvaez, Teresa wrote:

> Hello, 
>   I do not understand why I can't display images retrieved from MySQL
> on my browser(IE 4.0).  When I retrieve the image from MYSQL I set the
> Header function to change the type of content(image/gif) I am sending to the
> browser. However, the browser displays an box with an X in it.  I would
> greatly appretiate any ideas/help.  Here is the piece of code:  Thanks in
> advance! -Teresa
> 
>   Code to connect and selected DB not included
> -
> $dbQuery = "Select PicNum, size, type, description, Image";
> $dbQuery .= " FROM Images WHERE PicNum = $fileId";
> 
> $result = mysql_query($dbQuery)
> or die ("Could not get file list: " . mysql_error() );
> echo "Sent Query successfully";
> 
> if ( mysql_num_rows($result) == 1)
> {
> $fileType = @mysql_result($result,0, "type");
> $fileContent = @mysql_result($result, 0, "Image");
> $filedesc = @mysql_result($result,0, "description");
> $filenum = @mysql_result($result,0, "PicNum");
> //  Header("Content-type: $fileType"); 
> Header("Content-type: image/gif");
> echo $fileContent;
> }   
> else
> {
> echo "Record does not exist";
> } // else
> ?> 
> 


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