Jump to content

Recommended Posts

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/upload/scrview.php?fid=ZHBlcyBvdCB3cHJs.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).

[code]
<?php


require_once('ipb_integrator.php');
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));
fpassthru($fp);
exit;
}
else
{
echo "shite";
}

?>
[/code]
my code, that i've never had a problem w/

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

  header('Content-type: image/jpeg');
  header("Content-Disposition: inline; filename=".$filename);
  readfile($filePath);[/code]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.