RiposoEterno Posted July 4, 2006 Share Posted July 4, 2006 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.jpgALSO, 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 typeAlso, 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]<?phprequire_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] Quote Link to comment https://forums.phpfreaks.com/topic/13684-viewing-an-image-with-fpassthru-and-fopen-problem/ Share on other sites More sharing options...
micah1701 Posted July 5, 2006 Share Posted July 5, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/13684-viewing-an-image-with-fpassthru-and-fopen-problem/#findComment-53116 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.