• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

deleting image (file) from directory via a form.

Explorer ,
Mar 06, 2010 Mar 06, 2010

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>

TOPICS
Advanced techniques

Views

343

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 06, 2010 Mar 06, 2010

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 07, 2010 Mar 07, 2010

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation