如何将QR码作为图像文件存储到Mysql数据库中 [英] How to store QR code as image file in to Mysql Database

查看:56
本文介绍了如何将QR码作为图像文件存储到Mysql数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Laravel实现一个简单的应用程序. 只是想知道,当我通过电子邮件发送二维码时,是否需要先将二维码存储在数据库中以指定图像的文件传递?

I`m implementing a simple application using Laravel. just wondering, when I send qr code in email text, does qr code need to be stored in database first to Specify file pass for the image??

如果答案是肯定的,我有什么方法可以使用表单标签来存储二维码?

If that answer is yes, is there any way that I`m able to store qr code without using form tag?

推荐答案

您可以将图像转换为base64,然后将其存储为文本. 有关更多信息,请参见 http://php.net/manual/en /function.base64-encode.php 并解码 http://php.net/manual/en/function.base64-decode.php

You can do it converting image to base64 and then store it as text. for more information how to encode visit http://php.net/manual/en/function.base64-encode.php and for decode http://php.net/manual/en/function.base64-decode.php

示例编码:

$file_encoded = base64_encode(file_get_contents($file)); //this is stringed data. save this in database. 

示例解码:

$file_encoded = base64_decode ($file_encoded); //this will be file.

这篇关于如何将QR码作为图像文件存储到Mysql数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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