您可以向禁止访问该图像的用户显示默认的“禁止访问”图像:
<?php$file = $_GET['file']; // don't forget to sanitize this!header('Content-type: image/png');if (user_is_allowed_to_access($file)) { readfile($file);}else { readfile('some/default/file.png');}并且,在客户端:
<img src="https://www.mshxw.com/skin/sinaskin/image/nopic.gif" />
另外,如果您确实希望或需要通过Ajax发送数据,则可以对base64进行编码:
<?phpecho base64_enpre(file_get_contents($file));
并
img使用数据URI方案将响应放入标签中
var img = '<img />';
假设base64编码的数据明显大于原始数据,则可以发送原始数据并使用library在浏览器中对其进行编码。
这对您有意义吗?



