|
ColdFusion Home
Basic ColdFusionIntroductionColdFusion Installation ColdFusion Editors ColdFusion Syntax ColdFusion Includes ColdFusion Variables ColdFusion Variable Types ColdFusion If Statements ColdFusion Loops ColdFusion Datasource ColdFusion Database Queries ColdFusion Lists ColdFusion Arrays ColdFusion Redirect ColdFusion Debugging ColdFusion Error Handling Advanced ColdFusionColdFusion MailColdFusion Functions ColdFusion Components ColdFusion Web Services ColdFusion Upload File ColdFusion Read File ColdFusion Write File ColdFusion Append File ColdFusion Rename File ColdFusion Copy File ColdFusion Move File ColdFusion Delete File Cffile Parameters Using cffile Parameters ColdFusion FTP (cfftp) cfftp Cached Connections ColdFusion HTTP (cfhttp) ColdFusion Query of Queries ColdFusion Charts ColdFusion Summary ColdFusion AdminCF AdministratorCF Archive and Deploy CF Scheduled Tasks CF Mini Tutorial ColdFusion BooksColdFusion MX BibleMacromedia ColdFusion MX 7 Web Application Construction Kit Got a MySpace Page?Get "www.yourname.com" for your MySpace page. Learn how >>. |
ColdFusion Read FileYou can use ColdFusion's cffile tag to read a file from the server. To read a file, you use the cffile tag to write the contents of the file to a variable. Once you've done that, it's up to you what you do with the contents of that variable. You can display it to the user, or you could insert it into a database (using the cfquery tag). It's also quite likely that you will want to manipulate the contents before you do anything with it. Here's an example of reading an HTML file from the server, then outputting its contents:
Given this is an HTML file, the contents are interpreted by the browser: My Shopping List
If we wanted to view the source code, we could use ColdFusion's htmlCodeFormat() function when we output the results:
This results in:
<h3>My Shopping List</h3>
<ul> <li>Bananas</li> <li>Beans</li> <li>Vegemite</li> <li>Bread</li> <li>Rolled Oats</li> </ul> Binary FilesTo read a binary file (such as an image or a word processing document), you need use Next lesson shows you how to write files with ColdFusion. Enjoy this website?
Oh, and thank you for supporting Quackit! |
Featured Template:
(Build your websites in minutes!) |