title: How to properly use Coldfusion's FileExist() method?
body: <p>I don't use coldfusion much at all, I'm needed to patch up some code though.  Basically I'm trying to check and see if a file I uploaded exist and if it does exist, increment a variable by 1.  Then repeat untill I get a unique file name.  For whatever reason I can't figure out the proper way to use FileExist().  Some forums suggest using it with len() but those are from 2006 and when I do that it seems to always come out true.  Also, when I look at <a href="http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7c66.html" rel="noreferrer">http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7c66.html</a> it says it returns either Yes or No.  I tried to check against the result various ways, but no luck.</p>
  
  <p>This is the portion of code I have which I am dealing with.  The application.filepath is just a variable in my application file which store the expandpath().</p>
  
  <pre><code>&lt;cffile action="upload" destination="#Application.filePath#ListingsGallery/" filefield="iconImage" nameconflict="makeunique"&gt;
  &lt;cfset iconPlace = #cffile.serverfile#&gt;
  &lt;cfset myExt = listLast(iconPlace,".")&gt;
  &lt;cfset i = 1 &gt;
  &lt;cfset myVar = false&gt;
  &lt;cfloop condition="myVar EQ false"&gt;
  
      &lt;cfset newIconName = "iconPhoto" &amp; i &amp;"."&amp; myExt&gt;
      &lt;cfset iconName = Application.filePath &amp; "ListingsGallery/" &amp; #newIconName#&gt;
  &lt;cfoutput&gt;#iconName#&lt;/cfoutput&gt;&lt;br /&gt;//just checking to see if it is the correct path, it is.
  
      &lt;cfif FileExists(iconName) EQ 'Yes'&gt;
           &lt;cfoutput&gt;#myVar#&lt;/cfoutput&gt; //checking the value, it never hits here.
      &lt;cfelse&gt;
               &lt;cfoutput&gt;#myVar#&lt;/cfoutput&gt;&lt;br /&gt; //checking the value, it always hits here.
      &lt;cfset myVar = true&gt;        
               &lt;cfoutput&gt;#myVar#&lt;/cfoutput&gt; //Again check the value.
      &lt;/cfif&gt;
  &lt;cfset i++&gt;
  &lt;/cfloop&gt;                     
  &lt;cffile action="rename" source="#Application.filePath#ListingsGallery/#iconPlace#" destination="#Application.filePath#ListingsGallery/#newIconName#"&gt;
  </code></pre>
  
  <p>The absolute path on a unix server is something like,  /var/www/website folder name/ etc....
  Correct?  That's the absolute server path, the coldfusion docs seem to specify at least a microsoft absolute server path so I'm assuming this is what is needed. </p>
  
  <p>Edit---------------------------
  PS: I can' only give one of you credit, so I gave it to Kruger since he came a minute earlier.
  lol...</p>