Copy link to clipboard
Copied
Is there a way to use FileExists() with some sort of %webRoot% system variable, rather than me having to know the absolute path in advance? For example if my app is running on one machine where the webroot is C:\ColdFusion9\webroot\ and on another machine where it's E:\Inetpub\webroot, is there a way for me to write a single piece of code that will check for the existence of "%webroot%\webSite\myFile.cfm"?
I guess what I'm really looking for here, is a system variable called something like %webRoot% in ColdFusion 9... Does such an animal exist?
Thanks,
Laurence MacNeill
Mableton, Georgia, USA
Copy link to clipboard
Copied
Have a look at expandPath().
Perhaps have a breeze through all the functions CF has, to give you a general idea of what it can / "can't" do:
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7ff8.html
--
Adam
Copy link to clipboard
Copied
Let assume my function is contained in a .CFC file in C:\Inetpub\webroot\myapp\mycfcs
So if I used the following statement:
<cfif FileExists(ExpandPath(..\newcfcs\AttendeeInfo.CFC))>
it would return true if the file C:\Inetpub\webroot\myapp\newcfcs\AttendeeInfo.CFC existed, yes?
If that's the case, then great -- thanks!
L.
Copy link to clipboard
Copied
You can probably answer your own question by just... trying it!
Your syntax is slightly off, but other than that, yes. The docs are not clear. Where they say "an absolute path", it means "a string representing an absolute path", not just the path, unquoted.
But it's always good to do this sort of testing yourself...
--
Adam