Is it possible to find a file on a server and replacing specific text within that file via CF code?
I would like the user to make a selection from a drop down box and based on his/her selection, I would like to write code to locate the file, find data (within the file) that contains a certain phrase, and then replace that text based on the user's selection.
Thank you in advance to anyone who can assist/point me in the right direction.
I would like the user to make a selection from a drop down box and based on his/her selection, I would like to write code to locate the file, find data (within the file) that contains a certain phrase, and then replace that text based on the user's selection.
Code:
<cfif isdefined("form.change")>
<cfswitch expression="#form.color#">
<cfcase value="Green">
<cfif FileExists("c:\cfusionmx\[URL unfurl="true"]wwwroot\dtralink\index.cfm")>[/URL]
<cffile action="append"
file="c:\cfusionmx\[URL unfurl="true"]wwwroot\dtralink\index.cfm"[/URL]
output="#Replace("/operating_status/os_button_includes/green.cfm", "/operating_status/os_button_includes/yellow.cfm","one")#">
<cflocation url="index.cfm">
</cfif>
</cfcase>
<cfcase value="Red">
<cfif FileExists("c:\cfusionmx\[URL unfurl="true"]wwwroot\dtralink\index.cfm")>[/URL]
<cfif
<cfoutput>#Replace("/operating_status/os_button_includes/red.cfm", "/operating_status/os_button_includes/green.cfm","one")#"></cfoutput>
<cflocation url="index.cfm">
</cfif>
</cfcase>
</cfswitch>
</cfif>
<form action="#cgi.SCRIPT_NAME#" enctype="multipart/form-data" method="post">
<table border="0">
<tr>
<td>Select Status</td>
<td><select name="color">
<option value=""></option>
<option value="Green">Open</option>
<option value="Orange">Open - Early Dismissal</option>
<option value="Red">Closed</option>
<option value="Yellow1">Open - Unscheduled Leave</option>
<option value="Yellow2">Open - Delayed Arrival</option>
<option value="Yellow3">Delayed Arrival/Unscheduled Leave</option>
</select>
</td>
</tr>
<tr>
<td width="" valign="top" colspan="2" align="center"><br><input type="submit" value="Change Color" name="Change"></td>
</tr>
</table>
</form>
Thank you in advance to anyone who can assist/point me in the right direction.