| By Bruce Van Horn | Article Rating: |
|
| October 4, 2001 12:00 AM EDT | Reads: |
8,424 |
Q: What's OnRequestEnd.cfm?
A: OnRequestEnd.cfm is the twin brother of Application. cfm. When the code inside a file named Application.cfm is automatically included at the beginning of every .cfm file in the same subdirectory (and any directory below, provided that there isn't another Applic-ation.cfm in those directories), any code placed in a file named On-RequestEnd.cfm is automatically in-cluded at the end of every .cfm page.
Q: I come from an ASP background and am finding certain tasks difficult in ColdFusion. Here's my question: How do I find the size of a file on the server? I've looked everywhere. I have used the FileExists() function, but there really should be a FileSize() function.
A: I agree. There should be a FileSize() function (could be a great user defined function!). The size of a file, however, can be easily (though not intuitively) retrieved using the CFDIRECTORY tag. This tag is usually used for listing the contents of an entire directory or for creating, deleting, or renaming directories, but it can be used to retrieve information about a single file. Here's an example:
<cfdirectory action="LIST"
directory="C:\Inetpub\WWWRoot\
Datafiles"
name="qDir"
filter="AskCFDJ.mdb">
<cfoutput>#qDir.size#</cfoutput>
.
Q: I need to build a form that allows users to upload multiple files to my server. The <input type="file"> tag only allows a single file to be selected. How can I do this?
A: While the HTML <input type="file"> tag only allows you to select a single file, you can use as many of these tags as you like in your form. The trick is to have a CFFILE tag on the action page for every file uploaded. You can accomplish this by naming all of your <input type="file"> tags with similar names, like upload1, upload2, upload3, etc. You can then loop over your form fields to dynamically create the necessary CFFILE tags in your action page. Listing 1 provides an example.
Q: I'm having trouble feeding a quoted list to the IN operator in SQL. I run a query to retrieve certain city names from a database and then use the QuotedValueList() function to turn the results into a quoted list to be used in another query to retrieve only those records in which the cities match the list. My second query looks like this:
<CFQUERY NAME="GetCustomers" DATASOURCE="#dsn#">
SELECT Name, Address1, Address2, City, Phone
FROM Customers
WHERE City IN (#CityList#)
</CFQUERY>
When I look at the list, the city names are there with the appropriate single quotes around each entry (a requirement for the SQL IN operator when querying a text field), . but when I run this query in CF, I get a database error. What am I missing?
A: The problem is that CF automatically "escapes" single quotes inside the CFQUERY tag, so your list actually winds up with two sets of single quotes around each entry. What you need to do is use the Preserve-SingleQuotes() function on your list when you run it in CFQUERY. For example:
<CFQUERY NAME="GetCustoners" DATASOURCE="#dsn#">
SELECT Name, Address1, Address2, City, Phone
FROM Customers
WHERE City IN (#PreserveSingleQuotes(CityList)#)
</CFQUERY>
Q: I really like the ability to create my own functions (UDFs) in CF 5. Is there a place like the Developers Exchange at Allaire.com where I can upload the ones I've written and see what other people have created?
A: Yes. You should visit www.cflib.org, a great source of free UDFs founded by Raymond Camden and Rob Brooks-Bilson.
Please send your questions about ColdFusion (CFML, CF Server, or CF Studio) to AskCFDJ@sys-con.com. Visit our archive site at www.NetsiteDynamics.com/AskCFDJ.
Published October 4, 2001 Reads 8,424
Copyright © 2001 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Bruce Van Horn
Bruce Van Horn is president of Netsite Dynamics, LLC, a certified ColdFusion developer/instructor, and a member of the CFDJ International Advisory Board.
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Adobe May Cooperate with Apple to Transplant Flash Player to iPhone
- Adobe Flex Developer Earns $100K in New York City
- Adobe LiveCycle Enterprise Suite 2 for Cloud Computing
- Adobe Betas Target RIAs and Cloud Computing
- Adobe Cans Another 9% of its Workforce
- Moyea DVD4Web Converter V2.0 Converts DVD to FLV Fast and Synchronously with Watermarks
- Adobe Fiddles with its Web Apps
- Adobe & Salesforce Cut Cloud Deal
- Hosting.com Launches ColdFusion 9 in the Cloud
- The Real Time Infrastructure Ultimatum
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Eval JavaScript in a Global Context
- Fig Leaf Software to Exhibit at Government IT Conference & Expo
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Is Microsoft as Free as Open Source?
- Adobe Reader Sued
- The Planet Named “Bronze Sponsor” of Cloud Computing Expo
- Microsoft Expression Web Has Got Game
- Adobe May Cooperate with Apple to Transplant Flash Player to iPhone
- Adobe Flex Developer Earns $100K in New York City
- Bruce Chizen Joins Voyager Capital as Venture Partner
- My Top Seven Wishes From Adobe MAX 2009
- The Next Programming Models, RIAs and Composite Applications
- Where Are RIA Technologies Headed in 2008?
- Constructing an Application with Flash Forms from the Ground Up
- AJAX World RIA Conference & Expo Kicks Off in New York City
- CFEclipse: The Developer's IDE, Eclipse For ColdFusion
- Personal Branding Checklist
- Adobe Flex 2: Advanced DataGrid
- Has the Technology Bounceback Begun?
- Building a Zip Code Proximity Search with ColdFusion
- i-Technology Viewpoint: We Need Not More Frameworks, But Better Programmers
- The Asynchronous CFML Gateway
- Web Services Using ColdFusion and Apache CXF





















