• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 429
  • Last Modified:

cffile delete problem

Cannot understand why I am getting the error message below when running the action page code attached. The error message says the file is not available, yet it gives the correct pointer.

Hopefully something trivial that, while it escapes the novices eyes, is in neon lights to you all !!

thanks for any help


File D:\Inetpub\coin-des-artistes\abac_new\FORM TEXTAREA\photo3.JPG specified in action delete does not exist.  
The error occurred in D:\Inetpub\coin-des-artistes\abac_new\petit_images_listing_action.cfm: line 15
13 :
14 : <cffile action = "delete"
15 :     file = "#expandpath("./")#FORM TEXTAREA\<cfoutput>#url.name#</cfoutput>" >
16 :    
17 :    




<cffile action = "delete"
    file = "#expandpath("./")#FORM TEXTAREA\<cfoutput>#url.name#</cfoutput>" >
    File &nbsp;&nbsp;<cfoutput>#url.name#</cfoutput>&nbsp;&nbsp; has been deleted

Open in new window

  • 3
  • 3
1 Solution
The problem may be your quotes inside of quotes

file = "#expandpath("./")#FORM
       ^^              ^^

I like to build a variable with the full path so I can use/reuse it.  I also test it first.

Try this...


<cfset fullPath = expandpath("/") & "\FORM TEXTAREA\#url.name#">

<cfif FileExists(fullPath)>
   <cffile action = "delete" file = "#fullPath#">
   File &nbsp;&nbsp;<cfoutput>#url.name#</cfoutput>&nbsp;&nbsp; has been deleted
   File #fullPath# does not exist

Open in new window

Also using <cfoutput> inside your quotes may mess things up (leaving a space or something)

It is not necessary to use because it's inside a CF statement

  file = "#expandpath("./")#FORM TEXTAREA\<cfoutput>#url.name#</cfoutput>"
                                                              ^^^^^ remove

  not sure what this is referring to ./   is that the current directory?    The root should be just \
jameskaneAuthor Commented:
Many thanks for reply qdeMaria. You have solved my problem !!

the ./ is correct - given that the page I am debugging is at the same lever as the directory FORM TEXTAREA. If the page were inside the directory FORM TEXTAREA I would have used ../  Have found that this worked for me over a number of pages.

The solution was to take away the OUTPUT tags !!!  Would never have thought that in a million years. VERY many thanks.

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

jameskaneAuthor Commented:
Great, and thanks again !!
Glad to hear it's working!

> the ./ is correct - given that the page I am debugging is at the same lever

Just an FYI..  the current directory is typically designated by just "."  

jameskaneAuthor Commented:
Hummm... Just tried the . instead of the ./  

Does not work. ??
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now