?
Solved

CFFILE not creating new file

Posted on 2006-11-19
3
Medium Priority
?
246 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 2000 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
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…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

650 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