/    Sign up×
Community /Pin to ProfileBookmark

streaming image problem

ok either I am very tired or losing it but why does the page end after the image is displayed?

<?
$opts = array(‘http’=>array(‘method’=>”GET”,’header’=>”Accept-language: enrn”));

$context = stream_context_create($opts);

$fp = fopen(‘index_img/logo_pbs_wkno.jpg’, ‘rb’, false, $context);
fpassthru($fp);
fclose($fp);
print “hi”;
?>

I even tried replacing the fclose with just exit;

and nothing.

What I am trying to do is use the image in a page without showing the link to the image.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@HaganeNoKokoroOct 21.2004 — Why are you trying to do that? It won't stop anyone from stealing the image. It will still be downloaded onto their machine, they can still click on it and save-image-as. This next bit will sound a little harsh, but you seem, in fact, to be trying to hide stealing an image from another server, but without any evidence in the output html on your page. At least, if the image belonged to you, it seems logical you would just link to it, or copy it to your current server. I hope I'm wrong, but I just can't think of another reason to try something like this...

Unfortunately, the way web pages work is, the browser downloads the source. If it is text/html (ordinary webpage) then it looks through to see what else it needs to download, like images, applets, flash movies, etc. For each one in the page, it will create a new http request to the server, specifically for that file. The file will be returned with an appropriate content-type header from the server so the browser knows how to deal with the data.

So your idea won't work because, to display as an image, it has to have the Content-Type: image/jpeg, and then it won't know what to do with the text. It could even screw up the way your image looks becuase it may try to display the text as though it were image data. Or, if it is sent with a text/html or text/plain content-type, then it will display the image data as text, like if you open the image in notepad.
Copy linkTweet thisAlerts:
@daed17authorOct 21.2004 — Them downloading it is ok, I just don't want them seeing where the image resides.
Copy linkTweet thisAlerts:
@daed17authorOct 22.2004 — ok now that I got some rest, I figured out what I was doing wrong.
×

Success!

Help @daed17 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...