Solved

cffile delete problem

Posted on 2011-03-15
6
419 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
  • 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

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…
PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now