Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

cffile delete problem

Posted on 2011-03-15
6
Medium Priority
?
425 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 2000 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
Setting up LaraDock for Laravel

Learn how to set up LaraDock in a Laravel project - LaraDock gives us an easy way to run a Laravel application using Docker in a single command.

 

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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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 …
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

670 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