Base64 string to JPG
I am hoping someone can help with this. I am trying to take a Base64 string that is passed from a web form and, using ColdFusion (Version 6) conver that to a JPG image that can be posted to the server and a reference stored in a database.
I have the string being passed and it seems to be converting (at least it's creating a jpg file) but when I go to view the file, it's empty. If I view it in Preview on a Mac it says: "It may be damaged or use a file format that Preview doesn’t recognize."
Here is what I am using:
<head>
<cfif isdefined("form.imageName")>
<cfset newJPG = form.imageName>
<cffile action="write" file="#expandPath("images/newimage.jpg")#" variable="newJPG" output="#newJPG#" addnewline="no">
</cfif>
</head>
<body>
<cfoutput>
The string as an output <br /><br />
#newJPG#<br /><br />
The image as written back to a file<br /><br /><img src="#expandPath("images/newimage.jpg")#" /></cfoutput>
</body>
What am I doing wrong?
