Coldfusion 7: Saving Base64 Image to Server

417 Views Asked by At

A client needs us to generate a lot of dynamic QR codes for a project their doing. I think the end up being some hybrid between Name tags and event markers. In any case I've generated the QR just fine in JavaScript. Between JS and ColdFusion I'm even able to generate hundreds of dynamic QR codes in a second. The problem is now they're just sitting in the temporary memory of what ever client machine made them. I can send them as a form post in a 'text' input so I could begin something like a file upload, but that's where I stop having ideas.

How do I have these Base64 blob strings as PNGs on my server using ColdFusion?

I have CF7 so I don't have access to cfImage that I'm aware of.

2

There are 2 best solutions below

0
On

Instead of JavaScript, use Java to generate the image and save it to the file server. I've not used it, but zxing seems to be a popular Java based QR Code library.

1
On

Not sure I follow your question. There are probably easier ways to generate QR codes on the server depending on your environment. However, to answer your question, you should not need cfimage here. If you have a base64 string, just binaryDecode it into bytes. (That function should exist in MX7). Then save the bytes of the image to a file with the proper extension ie .png, jpg, etcetera.