Skip to content

Instantly share code, notes, and snippets.

@cfjedimaster
Created April 23, 2012 16:48
Show Gist options
  • Save cfjedimaster/2472221 to your computer and use it in GitHub Desktop.
Save cfjedimaster/2472221 to your computer and use it in GitHub Desktop.
<!---
Note - should add some logic to ensure file was properly image - can't trust the client
--->
<cfsetting showdebugoutput="false">
<cffile action="upload" filefield="afile" destination="uploads" nameconflict="makeUnique">
<cfset dataURL = "data:" & "image/" & cffile.clientfileext & ";base64," & toBase64(fileReadBinary(cffile.serverdirectory & "/" & cffile.serverfile))>
<cfset result = {"name":cffile.clientfile, "type":cffile.contenttype,"dataUrl":dataURL,"username":form.username,"accountnum":form.accountnum}>
<cfcontent type="application/json" reset="true"><cfoutput>#serializeJSON(result)#</cfoutput>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment