用Thinkphp3.2结合phpqrcode生成二维码

一个新手
Libérer: 2023-03-16 12:24:02
original
2458 Les gens l'ont consulté

首先,下载phpqrcode,将其解压到项目ThinkPHP\Library\Vendor目录下。
Index_index.html(模板可自行配置)


尺寸大小: 边距大小: 1px 2px 3px 5px 容错级别: Low (7%) Medium (15%) Quartile (25%) High (30%) 二维码内容: 二维码logo:
Copier après la connexion

控制器:IndexController.class.php


 3145728, 'rootPath' => './upload/', 'savePath' => '', 'saveName' => array('uniqid',''), 'exts' => array('jpg', 'gif', 'png', 'jpeg'), 'autoSub' => true, 'subName' => array('date','Ymd'), ); $upload = new \Think\Upload($config); // 实例化上传类 // 上传单个文件 $info = $upload->uploadOne($_FILES['test']); if(!$info) { // 上传错误提示错误信息 $qrcode_path_new = './Public/Home/images/code'.'_'.date("Ymdhis").'.png'; $content = $_POST['content']; $matrixPointSize = $_POST['matrixPointSize']; $matrixMarginSize = $_POST['matrixMarginSize']; $errorCorrectionLevel = $_POST['errorCorrectionLevel']; makecode_no_pic($content,$qrcode_path_new,$matrixPointSize,$matrixMarginSize,$errorCorrectionLevel); $this->assign('img',$qrcode_path_new); } else { $qrcode_path = "./upload/".$info['savepath'].$info['savename']; $content = $_POST['content']; $matrixPointSize = $_POST['matrixPointSize']; $matrixMarginSize = $_POST['matrixMarginSize']; $errorCorrectionLevel = $_POST['errorCorrectionLevel']; $url = "./upload/qrcode/".date("YmdHis").".png"; makecode($qrcode_path,$content,$matrixPointSize,$matrixMarginSize,$errorCorrectionLevel,$url); $this->assign('img',$url); } $this->display(); } }
Copier après la connexion

然后在项目Application/Home/Common下新建function.php



        
Copier après la connexion

在没有图片上传的情况下,生成我二维码只是单纯的二维码,只有在有logo上传的时候,才会生成带logo的二维码。

如下图,即没有logo时生成的二维码:

下图即在有图片被上传的时候生成的二维码:

Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!