How to hide image URL?

Prompt implementation:I have an img image on a page, I need to hide its url. That is, so that the user, when saving this picture, saves the php file, and not the picture itself.

So that I can’t get the real URL of the image for later download.

Maybe I’m wrong about something, your ways of solving this problem are interesting.


Answer 1, authority 100%

There is really one idea that I have not tried but should work … for example, the image is displayed in the browser via php

echo "<img src='/kartinka.php?img=1a'>";
$_SESSION['1a']=true;

and further code… When accessing the script, it checks the variable $_SESSION['1a']and if it is true, it displays a picture with an index in the array of pictures equal to 1a. (See how to do this separately.) And immediately removes the variable or makes it

$_SESSION['1a']=false;

Everything. The image will only be displayed in the browser when the page is loaded. It will not be possible to take it separately by clicking on the link.


Answer 2, authority 33%

Easiest way:

$handle = fopen("myfile.jpg", "r");
$contents = '';
while (!feof($handle)) {
  $contents .= fread($handle, 8192);
}
fclose($handle);
print($contents);