title: Issue with coldfusion cffile delete
body: <p>I have a page where a user can update a page with 4 images and some other fields.  There is already an image uploaded for each file input and when they upload a new one I want to take the new image, upload it then if the upload was successful delete the old image.  However I am getting this error.</p>
  
  <pre><code>File /var/www/mywebsite.com/Pics/Sunset3.jpg specified in action delete does not exist. 
  </code></pre>
  
  <p>The files does exist in that directory as per my ftp.  These files are even being displayed on the page as part of the form as a reference for the user as to what image is already there.  I've heard of not being able to process a file upload on the same page and you have to use a secondary file, but these images are uploaded on a previous visit to the page, so they are not being uploaded AND processed on the same page.  </p>
  
  <p>Here is the code I have.  The variable tableName is correct, it is defined earlier in the code, plus the database reflects the correct values after an upload attempt, it just breaks at the delete.</p>
  
  <pre><code>&lt;cfquery name="getPreviousImage" datasource="#Application.datasourceName#"&gt;
          SELECT 
              image1, image2, image3, image4
          FROM 
              #tableName#
          WHERE 
              RecordID = '#form.ID#'
  &lt;/cfquery&gt; 
  
  &lt;cfset oldImage1 = getPreviousImage.image1&gt;
  &lt;cfset oldImage2 = getPreviousImage.image2&gt;
  &lt;cfset oldImage3 = getPreviousImage.image3&gt;
  &lt;cfset oldImage4 = getPreviousImage.image4&gt;
  
  &lt;cfset image1 = getPreviousImage.image1&gt;
  &lt;cfset image2 = getPreviousImage.image2&gt;
  &lt;cfset image3 = getPreviousImage.image3&gt;
  &lt;cfset image4 = getPreviousImage.image4&gt;
  
  &lt;cfif #form.image1# NEQ ""&gt; 
  
      &lt;cffile action="upload" destination="#Application.filePath#Pics/" filefield="image1" nameconflict="makeunique"&gt;
      &lt;cfif isDefined ("cffile.serverFile")&gt;
          &lt;cfset image1Place = #cffile.serverFile#&gt; 
      &lt;/cfif&gt;
  
      &lt;cfif #getPreviousImage.image1# NEQ "" AND #image1Place# NEQ ""&gt;
          &lt;cffile action="delete" file="#Application.filePath#Pics/#oldImage1#"&gt;
      &lt;/cfif&gt;
  &lt;/cfif&gt;
  
  &lt;cfif #form.image2# NEQ ""&gt; 
  
      &lt;cffile action="upload" destination="#Application.filePath#Pics/" filefield="image2" nameconflict="makeunique"&gt;
      &lt;cfif isDefined ("cffile.serverFile")&gt;
          &lt;cfset image2Place = #cffile.serverFile#&gt; 
      &lt;/cfif&gt;
  
      &lt;cfif #getPreviousImage.image2# NEQ "" AND #image2Place# NEQ ""&gt;
          &lt;cffile action="delete" file="#Application.filePath#Pics/#oldImage2#"&gt;
      &lt;/cfif&gt;
  &lt;/cfif&gt;
  
  &lt;cfif #form.image3# NEQ ""&gt; 
  
      &lt;cffile action="upload" destination="#Application.filePath#Pics/" filefield="image3" nameconflict="makeunique"&gt;
      &lt;cfif isDefined ("cffile.serverFile")&gt;
          &lt;cfset image3Place = #cffile.serverFile#&gt; 
      &lt;/cfif&gt;
  
      &lt;cfif #getPreviousImage.image3# NEQ "" AND #image3Place# NEQ ""&gt;
          &lt;cffile action="delete" file="#Application.filePath#Pics/#oldImage3#"&gt;
      &lt;/cfif&gt;
  &lt;/cfif&gt;
  
  &lt;cfif #form.image4# NEQ ""&gt; 
  
      &lt;cffile action="upload" destination="#Application.filePath#Pics/" filefield="image4" nameconflict="makeunique"&gt;
      &lt;cfif isDefined ("cffile.serverFile")&gt;
          &lt;cfset image4Place = #cffile.serverFile#&gt; 
      &lt;/cfif&gt;
  
      &lt;cfif #getPreviousImage.image4# NEQ "" AND #image4Place# NEQ ""&gt;
          &lt;cffile action="delete" file="#Application.filePath#Pics/#oldImage4#"&gt;
      &lt;/cfif&gt;
  &lt;/cfif&gt;
  
  
  &lt;cfquery name="UpdateInfo" datasource="#Application.datasourceName#"&gt;
      UPDATE 
          #tableName#
      SET                  
          title = &lt;cfqueryparam value="#form.title#" cfsqltype="CF_SQL_VARCHAR" maxlength="250"&gt;,
          &lt;cfif #image1Place# NEQ ""&gt; 
              image1 =    &lt;cfqueryparam value="#image1Place#" cfsqltype="CF_SQL_VARCHAR" maxlength="250"&gt;,
          &lt;/cfif&gt;
          &lt;cfif #image2Place# NEQ ""&gt; 
              image2 =    &lt;cfqueryparam value="#image2Place#" cfsqltype="CF_SQL_VARCHAR" maxlength="250"&gt;,
          &lt;/cfif&gt;
          &lt;cfif #image3Place# NEQ ""&gt; 
              image3 =    &lt;cfqueryparam value="#image3Place#" cfsqltype="CF_SQL_VARCHAR" maxlength="250"&gt;,
          &lt;/cfif&gt;
          &lt;cfif #image4Place# NEQ ""&gt; 
              image4 =    &lt;cfqueryparam value="#image4Place#" cfsqltype="CF_SQL_VARCHAR" maxlength="250"&gt;,
          &lt;/cfif&gt;
          body = &lt;cfqueryparam value="#form.body#" cfsqltype="CF_SQL_VARCHAR"&gt;
      WHERE RecordID = &lt;cfqueryparam value="#form.ID#" cfsqltype="CF_SQL_INTEGER" maxlength="50"&gt;
  &lt;/cfquery&gt;
  </code></pre>
  
  <p>EDIT: 
  This is the new error after I implemented the fileExist().  Also, I see all of these images building up on my server.  I'm up to around sunset10.jpg among other photos.  If I get this fileExist to work wouldn't all it do is prevent the error from being displayed and the delete will never execute.  Because these files definitely do exist, unless I'm pointing to the wrong location of course.</p>
  
  <pre><code>Invalid CFML construct found on line 107 at column 138.
  ColdFusion was looking at the following text:
  
  &gt;
  
  The CFML compiler was processing:
  
  An expression beginning with #, on line 107, column 23.This message is usually caused     by a problem in the expressions structure.
  A cfif tag beginning on line 107, column 18.
  A cfif tag beginning on line 107, column 18.
  A cfif tag beginning on line 107, column 18.
  </code></pre>
  
  <p>I unfortunately cannot turn on robust exception reporting.  Also, this error is displayed when I first navigate to the page.  Before I even get a chance to submit the form.  Meanwhile this code is inside an if which should only execute after the form has been filled out.</p>