Solved

CFFILE not creating new file

Posted on 2006-11-19
3
237 Views
Last Modified: 2013-12-24
Hi all,

I have a function that creates a new file for logging: Here is a snippet of the code:

//logpath contains the DIRECT link to the folder in which the file to be saved
<cffile action="append" file="#logPath#" output="#content#" addnewline="yes">

Now, this code was working and the after some more testing (i deleted the file to ensure coldfusion would create the new file again) AND then this an error occured saying the file cannot be found. But isnt it supposed to create it?

Your help is greatly appreciated,




0
Comment
Question by:sydron
[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
  • 2
3 Comments
 
LVL 20

Expert Comment

by:trailblazzyr55
ID: 17979644
you have the action attribute set to "append" so it will look for the file, if it's not found it'll toss an error, you'd have to change the action attib to "write" for it to create a new file
0
 
LVL 20

Accepted Solution

by:
trailblazzyr55 earned 500 total points
ID: 17979668
you could do something like this...

<cfif fileExists(logPath)>
      <cffile action="append" file="#logPath#" output="#content#" addnewline="yes">
<cfelse>
      <cffile action="write" file="#logPath#" output="#content#">
</cfif>
0
 

Author Comment

by:sydron
ID: 17984623
Hi trailblazzyr55,

The CFFILE action="append" will create a file, if the file doest not already exist.

The actual problem with my code was that the value of the direct link was actually not valid, eg i had c:/websites file/wwwroot/etc.. rather than c:/websites/wwwroot/etc.

I have fixed the issue now.
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

707 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