jumpenjuhosaphat Posted May 17, 2007 Share Posted May 17, 2007 I would like to know if anyone knows how I could go about sending an image to the browser that is binary. Here is what I am doing right now...but it's not working: header("Content-Type: image/jpeg"); header('Content-Disposition: inline; filename="image.jpg"'); $theImage = $thePage->GetAs("image.jpg", 350, 270, 60); imagejpeg($theImage); I have an ASP script that I am going off of to pull this together, and it uses "Response.BinaryWrite", is there an equivalent in PHP? Quote Link to comment https://forums.phpfreaks.com/topic/51816-displaying-a-binary-image/ Share on other sites More sharing options...
neel_basu Posted May 17, 2007 Share Posted May 17, 2007 Here imagejpeg() is doing that job. e.g Its writting Binary data. Quote Link to comment https://forums.phpfreaks.com/topic/51816-displaying-a-binary-image/#findComment-255300 Share on other sites More sharing options...
jumpenjuhosaphat Posted May 17, 2007 Author Share Posted May 17, 2007 That's what I thought...But my result is a page with the page URL printed in the browser window, and no source code...And when I right click the text, it shows up like it is an image...ie "Copy Image", "Copy Image Location"....Etc. <?php if(isset($_GET['submit'])) { $url=$_GET['site']; $thePage = new COM("ABCDrawHTML2.Page"); $thePage->Url = ($url); header("Content-Type: image/jpeg"); header('Content-Disposition: inline; filename="image.jpg"'); $theImage = $thePage->GetAs("image.jpg", 350, 270, 60); $thePage->Save('C:/wamp/www/'.$url.'.jpg'); } ?> The image saves fine, but I am trying to avoid saving it, because I will be accessing this from a different server, and I don't want the images to overload my home computer. Quote Link to comment https://forums.phpfreaks.com/topic/51816-displaying-a-binary-image/#findComment-255303 Share on other sites More sharing options...
neel_basu Posted May 17, 2007 Share Posted May 17, 2007 Ya send the Binary data Directly to the Browser first do header("Content-Type: image/jpeg"); And then use imagejpeg(); To send the binary data directly to teh browser you dont need to save it. Quote Link to comment https://forums.phpfreaks.com/topic/51816-displaying-a-binary-image/#findComment-255307 Share on other sites More sharing options...
jumpenjuhosaphat Posted May 17, 2007 Author Share Posted May 17, 2007 Here is the full code: <?php if(isset($_GET['submit'])) { $url=$_GET['site']; $thePage = new COM("ABCDrawHTML2.Page"); $thePage->Url = ($url); $theImage = $thePage->GetAs("image.jpg", 350, 270, 60); header("Content-Type: image/jpeg"); header('Content-Disposition: inline; filename="image.jpg"'); imagejpeg($theImage); $thePage->Save('C:/wamp/www/'.$url.'.jpg'); } echo' <form method="get" action="david.php"> <input type="text" name="site"/> <input type="submit" name="submit"/> </form> '; ?> It doesn't even echo the form or the image at the end of the script.....The script stops without any errors for no apparent reason...I moved the ->GetAs, and the script continued until it came to that, and just quit.... Quote Link to comment https://forums.phpfreaks.com/topic/51816-displaying-a-binary-image/#findComment-255322 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.