2 Replies Latest reply on Mar 7, 2010 6:16 AM by cfinnov

    deleting image (file) from directory via a form.

    casegama

      I get the following error when I attempt to delete a record that includes an image file in a directory.  The image does truely exist  in the directory but the error states that it does not exist.  Any suggesstions?  Thanks for any help.

      Luis

       

      Here's my error....

      File C:\Websites\146416kd9\images\events\aski_150.jpg specified in action delete does not exist.

      The error occurred in C:\Websites\146416kd9\admin\events\edit.cfm: line 23
      Called from C:\Websites\146416kd9\admin\events\edit.cfm: line 16
      Called from C:\Websites\146416kd9\admin\events\edit.cfm: line 1
      21 :      </cfquery>
      22 : <cfif delEvent.SmallImage NEQ "">
      23 :   <CFFILE ACTION="delete" file="#EventImageLoc##delEvent.SmallImage#">
      24 : </cfif>
      25 : <cfif delEvent.LargeImage NEQ "">
      

       

      Here's my code....

      <cfif IsDefined("FORM.EventID") AND #FORM.EventID# NEQ "" AND IsDefined("FORM.delete")><!--- select then delete images --->
      <cfquery name="delEvent" datasource="#Request.DSN#">
        SELECT SmallImage, LargeImage
        FROM Events
        WHERE EventID = #FORM.EventID#
      </cfquery>
      <cfif delEvent.SmallImage NEQ "">
        <CFFILE ACTION="delete" file="#EventImageLoc##delEvent.SmallImage#">
      </cfif>
      <cfif delEvent.LargeImage NEQ "">
        <CFFILE ACTION="delete" file="#EventImageLoc##delEvent.LargeImage#">
      </cfif>
        <cfquery datasource="#Request.DSN#">
      DELETE FROM Events
      WHERE EventID=<cfqueryparam value="#FORM.EventID#" cfsqltype="cf_sql_numeric">
        </cfquery>
        <cflocation url="index.cfm">
      </cfif>