开发者

Is it possible to not expose my directory where I upload images?

开发者 https://www.devze.com 2023-03-01 14:56 出处:网络
In my website people can upload their photos. And I show them. Is it possible, that they would not be able to see url where that image is?

In my website people can upload their photos. And I show them. Is it possible, that they would not be able to see url where that image is?

Photos are shown like this <img src="http://mywebsite.com开发者_JS百科/my_images/image_name.gif" />. What I want to do, that people couldn't see that src link. Is there any way to show photos from that directory without exposing directory name?

Thanks.


There isn't, but you can use URL rewriting (apache's mod_rewrite or a custom PHP script to serve the images) to hide the actual location on your web server.

For example for the latter approach you coud have a serveimage.php on the server, which is called like serveimage.php?file=file1.jpg.


You can call another php-script via <img src="..."> the script loads the image and generates it. This FAQ entry should help.

0

精彩评论

暂无评论...
验证码 换一张
取 消