将base64 php字符串获取到img标签中
我有一个 php 文件“get.php”,它回显一个 base64 字符串。
我如何将其显示为另一个 .php 页面中的图像?
像这样的事情:
<img src="get.php?id=$lastid">
感谢您的帮助!
Ive got a php file 'get.php' that echo's a base64 string.
How would i display this as an image in another .php page?
something like this:
<img src="get.php?id=$lastid">
thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你可以做这样的事情:
但如果你的 BASE64STRING 是 php 的输出,那么这样的事情会起作用:
我知道这可能不完全是,但我希望你明白
You can do something like this:
but if you BASE64STRING is the output of a php, then something like this would work:
I know it may not be exactly but I hope you get the idea
如果您想将其显示为图像,则需要查看 GD 库并在生成图像后使用诸如
imagettftext()
之类的函数生成运行时图像,您的 PHP 脚本将发送标题说这是一个类似的图像,然后回显生成图像的二进制数据。
我为您找到了这个问题,它应该可以帮助您入门,请查看已接受的答案:
图像上的文字
If you want to display that as an image you will need to look into GD Library and generate a run time image using a function like
imagettftext()
after the image has been generated, your PHP script will send a header saying this is an image something likeand then echo the binary data of the generate image.
I found this question for you which should help you get started, look at the accepted answer:
Text on a image
不,您需要直接回显
get.php
的输出。为什么不在源代码的原始页面上包含并调用该函数?不要忘记,base64 字符串的开头需要data:image/png;base64,
或类似内容。No, you need to echo the output of
get.php
directly. Why don't you just include and call that function on the original page in source? Don't forget that the base64 string needsdata:image/png;base64,
or similar at the beginning.