是否有可能把二进制图像数据转换成HTML标记,然后在任何浏览器中得到照常显示图像? [英] Is it possible to put binary image data into html markup and then get the image displayed as usual in any browser?

查看:140
本文介绍了是否有可能把二进制图像数据转换成HTML标记,然后在任何浏览器中得到照常显示图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个重要的安全问题,我敢肯定这应该是可能的。

It's an important security issue and I'm sure this should be possible.

一个简单的例子:

您运行一个社区门户。用户注册并上传他们的图片。
你的应用提供了照片时允许显示安全规则。例如用户必须在每个侧面的朋友通过该系统,以便您可以查看其他人的上传照片。

You run a community portal. Users are registered and upload their pictures. Your application gives security rules whenever a picture is allowed to be displayed. For example users must be friends on each sides by the system, in order that you can view someone else's uploaded pictures.

下面问题来了​​:很可能有人抓取您的服务器的图像目录。但是,你要保护用户免受此类攻击。

Here comes the problem: it is possible that someone crawls the image directories of your server. But you want to protect your users from such attacks.

如果有可能把图像的二进制数据直接插入HTML标记,你可以限制你的图像显示目录的用户和组的Web应用程序运行的用户访问和图像数据传递到Apache的用户和直接组中的HTML。

If it's possible to put the binary data of an image directly into the HTML markup, you can restrict the user access of your image dirs to the user and group your web application runs of and pass the image data to your Apache user and group directly in the HTML.

唯一可能的弱点则是,你的Web应用程序运行的用户的密码。

The only possible weakness then is the password of the user that your web app runs as.

时已经有一种可能性?

推荐答案

有其他(更好)的方式,在其他的答案所述,为了保护您的文件,但是是有可能嵌入在HTML图像。

There are other (better) ways, described in other answers, to secure your files, but yes it is possible to embed the image in your html.

使用< IMG> 标签是这样的:

<img src="data:image/gif;base64,xxxxxxxxxxxxx...">

XXXXX ... 部分是GIF图像数据的base64编码。

Where the xxxxx... part is a base64 encoding of gif image data.

这篇关于是否有可能把二进制图像数据转换成HTML标记,然后在任何浏览器中得到照常显示图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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