如何在QR码生成器中插入图像和文本

时间:2017-07-11 04:54:12

标签: php codeigniter

在QR码生成器中插入图像和文本。扫描(文本和图像)后,两者都应出现在屏幕上。

我正在使用CIqrcode php(codeigniter)库。对于插入文本,它很好,但对于图像,路径显示在屏幕上。

我使用file_get_contents($path)并将其存储到$params['data']并将$params作为参数传递

$this->ciqrcode->generate($params,..,...,)

但屏幕上只显示路径。

对此有任何想法??

2 个答案:

答案 0 :(得分:0)

请使用下面提到的代码。另外,请确保您已为/assets/qrcode/文件夹授予了足够的权限。

$image = FCPATH . 'assets/qrcode/' . $id . '.png';
if (!file_exists($image)):
    $this->load->library('ciqrcode');
    $config['cacheable'] = true; //boolean, the default is true
    $config['quality'] = true; //boolean, the default is true
    $config['black'] = array(0, 89, 170); // array, default is array(255,255,255)
    $config['white'] = array(0, 89, 170); // array, default is array(0,0,0)
    $this->ciqrcode->initialize($config);

    $params['white'] = array(0, 89, 170); // array, default is array(255,255,255)
    $params['size'] = 100; //interger, the default is 1024
    $params['savename'] = $image;
    $params['data'] = '<img src="https://i.stack.imgur.com/ZfPaO.jpg" />';
    $params['level'] = 'H';
    $this->ciqrcode->generate($params);
endif;

答案 1 :(得分:0)

$filePath = null;
        if(LB_DESIGN) {
            $filePath = $this->filepath_model->getPathFolder_User($user_id);
        }else{
            $filePath = DE_PATH.'/web/test/file_system/user/'.$user_id;
        }
        $path = glob ($filePath."/photo.*");
        $img_src = null;
        if(count($path)){
             $file = basename($path[0]);
             $img_src = $filePath.'/'.$file;
         }else{
             $img_src = DE_PATH."/img/upload_logo.jpg";
         }
        $params['data'] = "Student Name: ".$row['certificate_name']."\nEmail ID: ".$emailId."\nAdmission No: ".$row['admission_no']."\nCourse Name: ".$row['course_name']."\nGrade: ".$grade."\nDate of Completion: ".$dateOfComplete."\nNOS/QPCode: ".$skill_code;
        $params['level'] = 'L';
        $params['size'] = 10;
        $data['myPath'] = $this->load->view('student_final_certificate');
        $params['savename'] = $data['myPath']."qrcode.png";
        $this->ciqrcode->generate($params);
    }
        return $data;   
  }//get html content