Jump to content


Viewing an image with fpassthru and fopen problem

  • Please log in to reply
1 reply to this topic

#1 RiposoEterno

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 04 July 2006 - 11:50 PM

Hey guys, i'm having problem with a php script of mine.

Basically it's opening and image and displaying it back to the browser (I don't want people to see the real location of the image).

The problem is, instead of displaying me back an image, when I go to the script it displays to me the page url and a blank view source. This is what I see: http://localhost/upl...yBvdCB3cHJs.jpg

ALSO, when I view page info, it's the right file size and the right mime type (image/jpeg), but doesn't display any image! and if I save page it saves it as a jpeg that when opened has no image, "preview not available".

Things you should know before you read the script:

the get_image_data function i have does work and gives back the right mime type
Also, this may be interesting, but if I remove the headers I do see the dump of the image file.

Please ignore anything in there that you don't know what it is, I can assure you that the file is being opened (like i said if i remove the header functions i see the image data dump).


global $ipsclass, $DB;

$file = $_REQUEST['fid'];
$loc = $ipsclass->vars['upload_dir']."/dls/dlscrs/";
$img = $IPBI->get_image_data($loc.$file);
$fp = fopen(ROOT_PATH."/uploads/dls/dlscrs/".$file, 'rb');
if ($fp)
	header("Content-Type: ".$img['mime']);
	header("Content-Length: ".filesize($loc.$file));
	echo "shite";


#2 micah1701

  • Members
  • PipPipPip
  • Advanced Member
  • 613 posts
  • LocationEllington, CT USA

Posted 05 July 2006 - 12:54 AM

my code, that i've never had a problem w/

$filename = "theFile.jpg"
$filePath = "hiddenPhotoDirectory/photos/".$filename;

  header('Content-type: image/jpeg');
  header("Content-Disposition: inline; filename=".$filename);

"Confidence in the face of risk."

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users