Copy link to clipboard
Copied
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>
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.