在codeigniter中生成qrcode

时间:2017-02-22 04:47:08

标签: php codeigniter qr-code

此代码适用于localhost但不适用于服务器:

public function user_generate_qr($u_id){

    $user_qr = $this->admin_model->get_user_data($u_id);
    $this->load->library('ciqrcode');

    $params['data'] = str_replace(" ","_",$user_qr['u_name']).'_'.$user_qr['u_dob'].'_'.$user_qr['u_gender'].'_'.$user_qr['u_email'].'_'.$user_qr['u_address'].'_'.$user_qr['u_mobile'].'_'.$user_qr['u_pincode'].'_'.$user_qr['user_code'].'_'.$user_qr['ref_code'];
    $params['level'] = 'H';
    $params['size'] = 20;
    $params['savename'] = QRPATH.'\a_'.str_replace(" ","_",$user_qr['u_name'].'_'.$user_qr['u_id'].'.png');
    $this->ciqrcode->generate($params);

    $this->load->helper('download');
    $data = file_get_contents(base_url().'public_html/qr_code/a_'.str_replace(" ","_",$user_qr['u_name'].'_'.$user_qr['u_id'].'.png'));
    $name = 'a_'.str_replace(" ","_",$user_qr['u_name'].'_'.$user_qr['u_id'].'.png');
    force_download($name, $data);

   // redirect("admin_ctrl/index");

    // echo '<img src="'.base_url().'public_html/qr_code/a'.$this->user['u_name'].'.png" />';

}

1 个答案:

答案 0 :(得分:0)

将所有文件复制到库中,然后编写此编辑

$this->load->library('ciqrcode');
header("Content-Type: image/png");
$params['data'] = 'This is a text to encode become QR Code';
$this->ciqrcode->generate($params);

enter image description here