Skip to main content
Inspiring
March 6, 2010
Question

deleting image (file) from directory via a form.

  • March 6, 2010
  • 2 replies
  • 392 views

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>

This topic has been closed for replies.

2 replies

March 7, 2010

Check before the delete step with fileexists.  Just dump  FileExists(absolute_path)  and see what does it  returns.Also, verify if the filename is correct.

Inspiring
March 6, 2010

Troubleshoot by doing a cfdirectory on your EventImageLocation variable and dumping the results.  Also dump the delEvent query. Do you see the files from the query in the directory?