How do you display an image that has been saved using md5 hashed value outside of web root?

StackOverflow https://stackoverflow.com/questions/16972424

  •  31-05-2022
  •  | 
  •  

I have a series of images I wish to display on a site using the HTML img tag.

e.g. <img src='some/location' />

However the image is located in a different directory outside of the web root. (but still on same server).

Moreover it has been saved as a hashed value using php's md5_file()

How do I go about displaying the image on the site, even if I can get to the file somehow, it has been saved differently?

有帮助吗?

解决方案

You have to do something like <img src="image.php?img=whatever">. Your image.php file will need to grab the image outside of the web root, as well as decode it for viewing.

You can force a .jpg (or whatever) extension using URL rewrites.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top