Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
rottmanja #1
cffile and read
I am working on a simple paperless transaction system, and for some reason I
can not get the attribute action='read' with cffile to work. I have read over
hte live docs and they are not very helpful. I have the variable attribute set
to test. But when I run the page it displays all the text in the .txt doc. How
can I set it up so that it only reads the var set to test.
rottmanja Guest
-
CFFILE ACTION=READ question
Hey Gang- I have a .cfm page that reads a text file using "cffile action=read" that I parse, read, loop through, etc. When I loop through the... -
CFFile read not working through mapped drive
I'm trying to use cffile to read a text file on a remote server through a mapped drive (d:) but getting the error : An error occurred when... -
cffile read and tab delimited files
I am attempting to read a tab delimited file which contains 11 pieces of data seperated by ten tab characters. In some cases there may be missing... -
File system get auto change from read-write to read-oly
I have a very strange file system with OS Redhat 7.2 The file system is read-write, but some how it randomly changes to read-only at any time.... -
Read & Read/Write Groups
I am trying to achieve a solution to a (hopefully) simple scenario. I have a Solaris 9 server that is going to be used for sharing files. I... -
kim il sung #2
Re: cffile and read
i dont undestand what you want. since you have not posted trouble code i can
only send sample code.
cffile is very simple to use. use cftry/cfcatch to trap file reading errors.
<cfset my_file="">
<cftry>
<cffile action="READ" file="d:\wwwroot\myfile.txt" variable="my_file">
<cfcatch type="Any">
error occured while reading file
</cfcatch>
</cftry>
<cfif my_file neq "">
file content:
#my_file#
<cfelse>
file content:
file reading failed
</cfif>
cheers, kim
kim il sung Guest
-
rottmanja #3
Re: cffile and read
I got it to work after going over a few things in my head. But how ever it
brings up another problem that I have seen with other aspects of cf. I have
attached my code below so you can understand what i am talking about. When I
use cfdirectory to create a new directory based on the file that cffile reads,
it creates a directory with weird chars after the data from the read file. EX.
it creates a directory with S050123 and two boxes behind it. The S050123 is
correct, but the boxes should not be there. (note I can not paste the boxes in
here for some reason)
<!-- Checks directory for .txt files -->
<cfdirectory action="list" name="chkDir" directory="#dir#" filter="*.txt">
<!-- Setting some Vars -->
<cfparam name="fileExists" default="no">
<!-- Reads files for file number -->
<cffile action="Read"
file="#dir##chkDir.Name#"
variable="readText">
<cfif DirectoryExists("#dir##readText#")is "NO">
<cfif FileExists("#dir##chkDir.Name#") is "Yes">
<cfset fileExists="yes">
<!-- Creates a new directory -->
<cfdirectory action="create"
directory="#dir##readText#" mode="">
<!-- Moves Files to the newly create directory -->
<cffile
action = "move"
source = "#dir##chkDir.Name#"
destination = "#dir##readText#"
mode = "777">
<!-- Renames the .txt file to the file number -->
<cffile
action = "rename"
source = "#dir##readText#"
destination = "#dir##readText#"
mode = "777">
</cfif>
</cfif>
<cfoutput query="getDir">
The files (#getDir.Name# exist on the server and have been moved to)<br>
<br>
The files are (#readText#)
</cfoutput><br>
rottmanja Guest
-
rottmanja #4
Re: cffile and read
Well I figured it out afterwards, I had forgotten to use the trim fucntion.
rottmanja Guest



Reply With Quote

