Passing Parameters in the URL - Cold Fusion

When an image is streamed from a script the script must be embedded inside an <img> and this causes problems when trying to pass variables through the application. A useful method is to use the URL to the embedded script to pass query string parameters.

The example on the previous page shows a script that draws a red square. With some modifications this colour could could be passed in the URL. Here is the new <img> tag:

<img src="image.cfm?Colour=FF0000">

The script generating the image would use the parameter as follows:

<cfobject action="create" name="Image" class="csImageFile.Manage">
<cfset Image.NewImage(200, 200, #URL.Colour#)>

Remember to encode the parameters using escape codes if they if they contain characters that will not pass through the URL.