Quick & Dirty QR Code Generator Using Coldfusion & cfimage tag

UPDATE #2 Please read my newer post which fixes a problem with the code below.

QR codes can be a great tool for marketing and engagement of customers. [UPDATE: But not without some risk ] I put together a simple Coldfusion page which allows you enter a url and get a QR code back. The code uses the Google Charts API and cfimage.

When you click create, we pass the value of the input field as a url variable to the Google API which returns a binary object. All we have to do is pass this result to cfimage  and write it to the browser. Done & Done. Works with CF8 & up

<script type="text/javascript">
function doIT(){
self.location = 'dsp_qrcodeGen.cfm?siteurl='+document.getElementById('siteurl').value //+ '&pdf=' + document.getElementById('pdf').value;
<div style="margin:auto; width: 600px; height:450px;padding:25px;text-align:center;border:1px solid;">
<h3>QR Code Generator</h3>
Input URL <input type="text" id="siteurl" style="width:500px;margin:50px 0 50px 0;"><br>
<button onclick="doIT();" id="btn">Create</button><br>
<cfif structkeyexists(url, "siteurl")>
<cfhttp url="http://chart.apis.google.com/chart?chs=200x200&cht=qr&chl=#url.siteurl#" result="qrcode" getasbinary="yes">
<cfimage action="writeToBrowser"
source="#qrcode.filecontent#" />

4 Responses to Quick & Dirty QR Code Generator Using Coldfusion & cfimage tag

  1. Pingback: A picture is worth a thousand malcious websites « Sid’s FishNet

  2. Pingback: QR Code Generator Update « Sid’s FishNet

  3. Ryan Trask says:

    Hey, really great script. Implemented in 1 minute and had it working.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: