Solved

cffile delete problem

Posted on 2011-03-15
6
422 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
How our DevOps Teams Maximize Uptime

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

 

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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

763 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