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

一个新手
Freigeben: 2023-03-16 12:24:02
Original
2458 Leute haben es durchsucht

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


尺寸大小: 边距大小: 1px 2px 3px 5px 容错级别: Low (7%) Medium (15%) Quartile (25%) High (30%) 二维码内容: 二维码logo:
Nach dem Login kopieren

控制器: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(); } }
Nach dem Login kopieren

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



        
Nach dem Login kopieren

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

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

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

Das obige ist der detaillierte Inhalt von用Thinkphp3.2结合phpqrcode生成二维码. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!