Suppose I have a XML file:
<?xml version="1.0"?>
<person>
<name>
<firstname>John</firstname>
<lastname>Barrett</lastname>
</name>
</person>
Now I want to add another name to this XML file. How can I create a CF form (I am fine with creating the form) and post the content of that form (user input) to update the xml file?
Solution
A new record can be inserted by first reading the xml file to a varaible using cffile. The new record may then be inserted using ArrayAppend and XmlElemNew functions before finally writing it to file using cffile again.
you want to encode a string using the base 64 system and then decode it back.
Solution
Merely use the base64 method in CF for encoding. Decoding will be a two step process. first, the encoded string is converted to binary and then converted to string.
A ColdFusion application requires a valid email address be entered in a form.
Solution
ColdFusion allows the use of Regular Expressions to do pattern matching against a string with the REFind and REFindNoCase functions. Using the REFindNoCase function will allow an application to determine if a string is a valid email address. The IsValid function can also be used to accomplish this task.
You need to store an image, but perhaps only have access to a database and not a file system. There are many examples of this now with cloud architecture becoming more popular.
Solution
Turn the image in to a ColdFusion Image object so you can manipulate the image if needed, and then turn it back into a BLOB using ImageGetBlob().
Allowing users to upload image files, which are then displayed, can seem extremely simple but has its challenges and security concerns. The main danger is the fact that much of the information available to us at the time of an upload request is supplied by the client/browser, which means all of that information has the potential to be "spoofed" by an unscrupulous hacker.
Solution
We can safely upload image files by uploading to a temporary (non-Web-accessible) directory and then moving beneath the Web root once we're certain we have a safe and valid image file.
I want to create a method that allows my visitors to switch style sheets without the use of JavaScript in ColdFusion. Can this be done?
Solution
Yes, to accommodate different user circumstances there are many different methods that are used to switch styles on a web page. The most popular method is to switch the CSS (Cascading Style Sheets) using JavaScript on the client side. Ironically, by using 'some' of the JavaScript methods you could be making your site even less accessible to the end user. Here is a simple method you can implement in ColdFusion a server side technology that does not depend of the use of JavaScript.
This site is produced in partnership with O'Reilly.