PHP的base64验证连接codeD映像 [英] PHP Validate base64 encoded images

查看:159
本文介绍了PHP的base64验证连接codeD映像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要找到一种方法来验证的形象是连接的base64在PHP中codeD。

I need to find a way to validate an image that is base64 encoded in PHP.

通过验证我在想XSS和类似的其他安全的事情。

By validate i'm thinking of XSS and other security things like that.

的流程是:

用户有一些参数,其中,他们一个base64 EN图像code串的一个OG越来越张贴到我的网站。当我收到称为IMG1参数FX具有的base64 EN codeD映像字符串值。

User has some parameters where one og more in a base64 encode string of an image and post them to my site. When i receive the parameter fx called img1 with the base64 encoded image string as value.

然后,我会想,以确保这一带的base64 codeD字符串只包含图片的所行没有任何标签和任何其他的东西黑客会尝试使用。

I would then like to make sure that this base64 encoded string only consist of the image and doest not have any tags and any other things hackers will try to use.

没有人知道任何PHP函数或插件,可以帮助我?

Does anyone know any PHP functions or plugins that can help me?

推荐答案

您可以尝试从使用的 imagecreatefromstring 功能。

You can try to create the image from the string using the imagecreatefromstring function.

然后,您可以测试图像尺寸/类型。

You can then test for image dimensions/type.

如果你想多走一步,你可以创建一个新的图像,然后尝试将用户图像复制到它,并以此作为最终图像。由于最终图像最初是由您创建有一个机会非常渺茫任何黑客可以拿到直通。

If you want to go one further step you can create a new image and then attempt to copy the user image onto it and use this as the final image. Since the final image was initially created by you there is a very slim chance any hacker could get thru.

这篇关于PHP的base64验证连接codeD映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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