显示来自网站根外部的图像 [英] Displaying images from outside the site root

查看:120
本文介绍了显示来自网站根外部的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里提出了一个类似的问题

从文档根目录以外提供图片



给出并接受的解决方案是使用Apache别名。



然而,文件夹的Apache别名是否也公开了?我想提供一个形象,并在公众眼中保持其隐形性。

有没有人知道除了别名以外的其他解决方案来提供文档根外的图像?



任何帮助将不胜感激。

解决方案

您可以做这样的事情...

 <?php 

//以某种方式从查询字符串或数据库中分配$ file或
标题(Content-length:。filesize($文件));
header(Content-type:。mime_content_type($ file));
readfile($ file);


A similar question was asked here

Serving images from outside of document root

The solution given and accepted was using Apache Aliases.

However, does an Apache Alias of a folder just make it public as well? I would like to serve an image and maintain its invisibility in public eyes.

Does anyone know any other solutions to serving images outside of the document root besides the Alias?

Any help would be greatly appreciated.

解决方案

You could do something like this...

<?php

// somehow assign $file from a query string or database or whatever
header("Content-length: ". filesize($file));
header("Content-type: ". mime_content_type($file));
readfile($file);

这篇关于显示来自网站根外部的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆