如何隐藏图像的物理路径 [英] How to hide the physical path of the images

查看:96
本文介绍了如何隐藏图像的物理路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我通过给出目录的物理路径(例如 http)来显示用户的图像: //www.example.com/user_images/abcdefghijk.jpg

In my application i display the image of user by giving the physical path of the directories like http://www.example.com/user_images/abcdefghijk.jpg

但是我不想将此物理路径暴露给外部用户以访问直接文件. 我想按照gravtar类型的图像显示来实现图像检索.我们该怎么做?

But i dont want to expose this physical path to the external users to access the direct files. I want to implement the image retrieval as per the gravtar type image display. How we can do that?

推荐答案

在PHP中,您可以使用GD库读取图像.因此,您唯一需要创建image.php文件的方法使用以下代码,

In PHP you can use GD library to read the image. So the only way you need to create a image.php file & use the following code,

<?php
$imagepath="your image physical path";

$image=imagecreatefromjpeg($imagepath);

header('Content-Type: image/jpeg');
imagejpeg($image);
?>

这是用于jpg图片的所有其他图片,您可以在GD库中使用不同的功能.

this is for jpg image for all other images you can use different functions fo GD library.

因此Gravtar.com使用上述方法来显示图像:)

So Gravtar.com uses the above way to display the image :)

在ROR中,您可以使用Rmagick gem读取图像&以相同的方式显示图像.

In ROR you can use Rmagick gem to read the image & display the image with the same way.

谢谢

这篇关于如何隐藏图像的物理路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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