简体   繁体   English

如何显示非公共文件夹中的照片?

[英]How to display photo from non-public folder?

I have built my website in a way so that the actual database files are positioned as follows 我以某种方式构建了我的网站,以便实际数据库文件的位置如下

root/
root/httpdocs <- public folder
root/databasefolder/actual_files_here/some_photo.jpg

How can I implement so that the php can view/load a photo from that databasefolder and echo it with tag. 我该如何实现,以便php可以查看/加载该数据库文件夹中的照片并使用标记将其回显。 I simply tried "../databasefolder/" in a tag, but it doesn't work (of course it doesn't), since it's from hidden folder. 我只是在标签中尝试了"../databasefolder/" ,但是它不起作用(当然不起作用),因为它来自隐藏文件夹。

I tried Base64 which works in other browsers, but not with Internet Explorer, due to that silly kb limit. 我尝试了Base64,该Base64可以在其他浏览器中使用,但不能与Internet Explorer一起使用,因为该KB限制很有限。

In your HTML: 在您的HTML中:

<img src="image.php?image=some_photo.jpg" />

And a php script that echoes your image. 和一个PHP脚本,呼应你的形象。

header('Content-type: image/jpeg');
echo imagejpeg('root/databasefolder/actual_files_here/' . $_GET['image']);

You can use the get parameter "image" to load whatever image you need from that folder. 您可以使用get参数“ image”从该文件夹加载所需的任何图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM