Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/51816-displaying-a-binary-image/
Share on other sites

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. 

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....

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.