Hey all, I have been thrown into a new job at work, our CF developer is gone and I need to pick up his job and I have hit a stumbling block in what I am sure is an easy fix. But until I learn more as I go this has got me stumped. We have several websites, and at the bottom of of our sites we refrence our other sites. So I have been asked to create a centralized text file that has some html code to display an image that is a link. How do I render this text file within CF, so far I have this. <cffunction name="HRefs"> <cfhttp url="http://www.sitename.com/hrefs1.txt" method="get" timeout="60"> <cfreturn #cfhttp.fileContent#> </cffunction> <cfoutput>#htmlCodeFormat(HRefs)#</cfoutput> But all I get at the bottom is this. cftypicallayout2ecfm1480391653$funcHREFS@1feb75 The text file just contains html code like this. <a href="http://www.sitename1.com" alt="text1"><img src="_img/sr_tiny.JPG" alt="image alt1" border ="0" /></a> <a href="http://www.sitename2.com" alt="text2"><img src="_img/sr_tiny.JPG" alt="image alt2" border ="0" /></a> Any help would be great, even if you just point me to an online tutorial to work my way through this would be great. Thanks,
I believe it would be easier to use the CFFILE tag with the "read" attribute, see here for a description: cfquickdocs DOT com/#cffilee You can then just display the text with CFOUTPUT.
Thanks nerveman, I followed the instructions within the site that you linked, this is the code I am instructed to use. <cffile action = "read" file = "http://www.somesite.com/hrefs1.txt" variable = "HRefs"> <cfoutput>#HRefs#</cfoutput> However this is the error that follows. Security: The requested template has been denied access to cffile. The following is the internal exception message: access denied (coldfusion.tagext.GenericTagPermission cffile) Now I realize what that is telling me, but I am not sure how to fix it.
I can access the file by just entering it into my browser and it renders the text as html fine, so I am a little lost as to why the CF page is telling me there is a security problem.
Here is the fix to my issue, incase anyone else ever needs it. <cfhttp url="http://www.somesite.com/hrefs1.txt" timeout="10"> <cfif IsDefined("CFHTTP.FileContent")> <cfoutput>#CFHTTP.FileContent#</cfoutput> </cfif>