0

How to set img src for images that are only downloadable?

I have created donwload.php for image downloading using link.

I have set an access restriction on images, so images will be only accessible through download.php.

I want to use this image in img tag like this.

<img src="donwload.php?url=images/something.jpg" />

But this is not working. Please help me on this.

Community
  • 1
  • 1
Sanky
  • 377
  • 2
  • 6
  • 14

1 Answers1

1

First, you can't really prevent anyone from right-clicking an image and selecting "Save Image As…". ;-)

Your problem is easily solvable though. Embed your images as usual and wrap those you want to be downloadable with <a> tags point to your download.php file:

<a href="download.php?url=images/something.jpg" target="_blank">
    <img src="images/something.jpg" />
</a>
nietonfir
  • 4,797
  • 6
  • 31
  • 43