marc22
marc22

Reputation:

How detect is GET request is made by embed "src"?

Is there any way to detect in PHP is GET request made by embed src in browser?

<img src="xxxxx.php">

I was trying use "REFFER", but it's very not good solution.

I don't know lot about http, but maybe if browser use tag, it send header accept image or anything like this what i can read in php ?

I just want create script what will display picture if embed, but if open in browser in normal way, like url it will redirect user to other page.

Upvotes: 1

Views: 595

Answers (3)

SleepProgger
SleepProgger

Reputation: 364

You can (but i would NOT suggest it) check the Accept header.
If the request was triggered by an <img src=... it should NOT contain "text/html".
Also described here

But again: i would not suggest using this.
At the moment that will break the download image functionality in firefox and possible other browser.
Additionally it won't prevent "evil guys" to download all your images because they simply can set the required HTTP header.

Upvotes: 0

Zoe Edwards
Zoe Edwards

Reputation: 13707

If you hide your files in a folder outside the root, created a PHP file that all images routed through (image.php?lovely_duck.jpg) and then looked for $_SERVER['HTTP_REFERER'], that would be possible. But you can forge $_SERVER['HTTP_REFERER'] and it isn’t always reliable.

If you’re trying to find a way to stopping people getting your images, they’ll always find a way.

Upvotes: 0

Quentin
Quentin

Reputation: 944197

Is there any way to detect in PHP is GET request made by embed src in browser?

No.

Upvotes: 3

Related Questions