Quantcast
Viewing all articles
Browse latest Browse all 16

Q R Code Generator In Yii Framework

Q R Code Generator In Yii Framework & Save image in folder.

step – 1
download the yii extension
http://phpqrcode.sourceforge.net/
qrcode.zip
save this protected/extensions/qrcode

step – 2
Upload code for Q R Code image

//set it to writable location, a place for temp generated PNG files
$PNG_TEMP_DIR = dirname(__FILE__).DIRECTORY_SEPARATOR.’temp’.DIRECTORY_SEPARATOR;

//html PNG location prefix
$PNG_WEB_DIR = ‘temp/’;

include “qrlib.php”;

//ofcourse we need rights to create temp dir
if (!file_exists($PNG_TEMP_DIR))
mkdir($PNG_TEMP_DIR);

$filename = $PNG_TEMP_DIR.’test.png’;

//processing form input
//remember to sanitize user input in real-life solution !!!
$errorCorrectionLevel = ‘L’;
if (isset($_REQUEST['level']) && in_array($_REQUEST['level'], array(‘L’,’M’,’Q’,’H’)))
$errorCorrectionLevel = $_REQUEST['level'];

$matrixPointSize = 4;
if (isset($_REQUEST['size']))
$matrixPointSize = min(max((int)$_REQUEST['size'], 1), 10);

if (isset($_REQUEST['data'])) {

//it’s very important!
if (trim($_REQUEST['data']) == ”)
die(‘data cannot be empty! back‘);

// user data
$filename = $PNG_TEMP_DIR.’test’.md5($_REQUEST['data'].’|’.$errorCorrectionLevel.’|’.$matrixPointSize).’.png’;
QRcode::png($_REQUEST['data'], $filename, $errorCorrectionLevel, $matrixPointSize, 2);

} else {

//default data
echo ‘You can provide data in GET parameter: like that


‘;
QRcode::png(‘PHP QR Code Image may be NSFW.
Clik here to view.
:)
‘, $filename, $errorCorrectionLevel, $matrixPointSize,2);

}


Filed under: Uncategorized Tagged: php, QR code generation, YII Framework Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 16

Trending Articles