51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?php
|
|
ini_set('display_errors', 'On');
|
|
error_reporting(E_ERROR);
|
|
|
|
require_once COMMPATH . 'third_party/phpqrcode/phpqrcode.php';
|
|
|
|
/**
|
|
* Notes:私或通专题页
|
|
* Created on: 2020/10/13 14:13
|
|
* Created by: dengbw
|
|
*/
|
|
class Myqrcode extends CI_Controller
|
|
{
|
|
|
|
/**
|
|
* Notes:
|
|
* Created on: 2020/10/14 10:49
|
|
* Created by: dengbw
|
|
* https://liche-dev.xiaoyu.com/h5/syt/qrcode
|
|
*/
|
|
function get()
|
|
{
|
|
$url = $this->input->get('url');
|
|
if ($url) {
|
|
$errorCorrectionLevel = 'L'; //容错级别
|
|
$matrixPointSize = 5; //生成图片大小
|
|
//生成二维码图片
|
|
QRcode::png($url, false, $errorCorrectionLevel, $matrixPointSize, 1);
|
|
}
|
|
}
|
|
|
|
function save()
|
|
{
|
|
$basedir = '';
|
|
$saveDir = '要保存的目录地址';
|
|
if (!is_dir($saveDir)) {
|
|
mkdir($basedir);
|
|
chmod($basedir, 0777);
|
|
}
|
|
if (is_dir($saveDir)) {
|
|
$filename = $saveDir . '/qrcode.png';
|
|
$qrcode_content = 'hello qrcode';//二维码的内容
|
|
ob_clean();
|
|
QRcode::png($qrcode_content, $filename);
|
|
echo $filename;
|
|
} else {
|
|
exit('目录创建失败');
|
|
}
|
|
}
|
|
|
|
} |