Solved

CFFILE not creating new file

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
json_decode return null? 8 69
file too large for website 6 67
Splitting up a coldfusion site into 2 separate sites in IIS 3 88
How to switch email hosts (part 2) 11 66
In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
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.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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

13 Experts available now in Live!

Get 1:1 Help Now