用Thinkphp3.2結合phpqrcode產生二維碼

一个新手
發布: 2023-03-16 12:24:02
原創
2458 人瀏覽過

首先,下載phpqrcode,將其解壓縮到專案ThinkPHP\Library\Vendor目錄下。
Index_index.html(模板可自行配置)


#
尺寸大小: 边距大小: 1px 2px 3px 5px 容错级别: Low (7%) Medium (15%) Quartile (25%) High (30%) 二维码内容: 二维码logo:
登入後複製

控制器: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(); } }
登入後複製

然後在專案Application/Home/Common下新建function.php



        
登入後複製

在沒有圖片上傳的情況下,產生我二維碼只是單純的二維碼,只有在有logo上傳的時候,才會產生帶有logo的二維碼。

如下圖,也就是沒有logo時產生的二維碼:

下圖即在有圖片上傳的時候產生的二維碼:

以上是用Thinkphp3.2結合phpqrcode產生二維碼的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!