Solved

CFFILE not creating new file

Posted on 2006-11-19
3
231 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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JVM encoding. How to change encoding. 27 122
WAMP server installation, getting error popups, DLLs missing 5 85
Question to locate the problem 18 134
spamming  on Hosted svrs? 6 105
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
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…

697 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