Solved

cffile delete problem

Posted on 2011-03-15
6
423 Views
Last Modified: 2012-05-11
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

james
++++++++++++++++++++++++++++++++++++++++++++++++++++
ERROR MESSAGE

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 :    
 

--------------------------------------------------------------------------------


 

<cfoutput><h2>#url.name#</h2></cfoutput></h3>

<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

0
Comment
Question by:jameskane
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 39

Expert Comment

by:gdemaria
ID: 35139709
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...

<cfoutput><h2>#url.name#</h2></cfoutput></h3>

<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
<cfelse>
  <cfoutput>
   File #fullPath# does not exist
   </cfoutput>
</cfif>

Open in new window

0
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
ID: 35139731
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 \
0
 

Author Comment

by:jameskane
ID: 35139942
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.

JAMES
0
Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

 

Author Closing Comment

by:jameskane
ID: 35139958
Great, and thanks again !!
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 35140015
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 "."  

0
 

Author Comment

by:jameskane
ID: 35140118
Hummm... Just tried the . instead of the ./  

Does not work. ??
0

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question