1
\$\begingroup\$

I am trying to create a CAPTCHA image on ColdFusion. ColdFusion will be producing REST services and hence will have to push the image via JSON. I want the image to be self contained. I don't want to expose any of the servers paths, so I am going to encode the image and push that via JSON. Last but not least, Vue.js will be used to show the image on the page.

Note: I have omitted the AJAX part for clarity.

<cfscript>
 // This is ColdFusion
 tempFile = "ram:///myImage.txt";
 myImage = ImageCreateCaptcha(100, 300, "Blackcat", "high");
 ImageWriteBase64(myImage, tempFile, "png",true, true);
 myfile = FileRead(tempFile);
 FileDelete(tempFile);
</cfscript>
<div id="image">
 <img :src="captcha">
</div>
<script>
 // this is JavaScript
 data = { 'captcha' : <cfoutput>'#myfile#'</cfoutput> };
 new Vue({
 el: '#image',
 data : data
 });
</script>

Can this process be improved?

Jamal
35.2k13 gold badges134 silver badges238 bronze badges
asked Apr 28, 2018 at 6:45
\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

Be careful with storing intermediate data to disk, including RAM disk. Because it is shared by the whole server, it is even worse than a global variable! The data you write may not be the data you read.

answered Apr 28, 2018 at 12:39
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.