ColdFusion Muse

Site by Site Missing File Handler in IIS

Mark Kruger September 7, 2006 2:29 PM Coldfusion MX 7, Coldfusion Tips and Techniques Comments (6)

Perhaps you've used my previous blog on IIS and missing file handlers to solve the problem of dynamically named folders or files. You might think that using the 404 handler in IIS in conjunction with your site wide missing template handler (set in the CFIDE Administrator) is your only option. What if you are on a shared server? Is there a way to implement a site by site missing template handler? Why yes Virginia there is.

Read More
  • Share:

Matching MIME and Extension After Upload

Mark Kruger August 10, 2006 10:58 AM Coldfusion MX 7, Coldfusion Tips and Techniques Comments (1)

Muse Reader Asks:
How can I check that the extension of an uploaded file matches the mime type?

If you read my previous post, I presume what you mean is "how do I make sure the file is what it says it is". Unfortunately this is not as easy as it seems. MIME, as it turns out, has little to do with the file. It's an attribute that tells an OS what to do with content after it's been transmitted. In fact, MIME was originally designated as a way of setting up boundary containers in an email message to facilitate attachments. As you may know, SMTP only handles character data - not binary data. When you send an attachment it is actually encoded as character data. The MIME type tells the receiving client to put the file back together as a certain type of file. That's pretty much where MIME ends...

Read More
  • Share:

MIME Types, Coldfusion and You

Mark Kruger August 2, 2006 11:06 AM Coldfusion MX 7, Coldfusion Tips and Techniques Comments (4)

Sometimes you need to be able to specify the MIME type using Cfcontent or inline headers to force the file to open in the proper application. If you have a document storage application or a data export application you know what I mean. For example, an engineering firm might upload CAD files, Office files, PDFs, images, and proprietary formats that you have never seen before. If you are like me, you end up writing code that switches against the file extension to set the mime type. Yesterday I saw a note from Dan Switzer from Pengoworks (of qForms fame) that can get the mime type using the file path. It's not perfect as I'll explain - but here it is:

Read More
  • Share:

Maintaining Your Session Across Sub Domains

Mark Kruger July 28, 2006 7:33 PM Coldfusion Tips and Techniques Comments (25)

One of the clever things you can do to personalize your site is to give individuals or clients or affiliates (or your dog) a custom URL. For example, if I wanted to give my dog his own url on my "" domain I could create "". Now, unless you want to spend most of your time entering CNAME or A records into your DNS server I suggest the following:

Read More
  • Share:

Coldfusion and DTS - Easy Exporting

Mark Kruger July 26, 2006 4:43 PM MS SQL Server, Coldfusion Tips and Techniques Comments (26)

What do you do when you are required to provide a CSV export of a large dataset from MS SQL Server? You could use query2csv and export it in Coldfusion - but don't be surprised if you end up taking a long time to complete that request. Coldfusion, for all it's advantages, it is not suited to to this sort of thing. We had a process that exported 30,000+ records (just a few fields) for the purpose of sales calculations. In Coldfusion this resulted in a 6 meg file - that doesn't sound like much, but the process could take 5 minutes or more. We thought of DTS, but one of our requirements was to make the file accessible via FTP. Fortunately there was an easy way.

Read More
  • Share:

Ask-A-Muse: Duplicating PHP Array Syntax In Coldfusion

Mark Kruger July 3, 2006 6:07 AM Coldfusion Tips and Techniques Comments (1)

CF Muse Reader, Rashid Aslam Asks:
Can i do the same kind of array initialization in Coldfusion as I do in PHP. Like This:

    $lang['abrvdays'] = array("Sun", "Mon", "Tue");

Actually, using a list to create an array in Coldfusion is slightly easier than creating and populating an array from scratch. Instead of arrayNew() followed by set statements you can simply use the listToArray() function.

<cfset abrvdays = listToArray("Sun,Mon,Tues")>
It takes a list, like the one above and there is an optional "delimiters" argument that you can include as well. For example, to create an array from my domain name I could specify periods like so:
<cfset arrDomain = listToArray("",".")>

  • Share:

Using Coldfusion To Handler 404 Errors

Mark Kruger June 13, 2006 1:44 PM Coldfusion Tips and Techniques Comments (9)

CF Muse Reader (Megan @ cybersense) Asks:
A client wants to be able to send an email link like this, - where 23 is the id of the property. I thought if I added some code to application.cfm I could detect this, and forward it to the right place but 404 reigns supreme. Can it be done and where do should I start?

Ah, this is easier than you think. The only tricky part is that it requires a change in your IIS or Apache settings. Here are the steps:

NOTE: See the comments for some additional nuances!

Read More
  • Share:

Great Tip - Capturing "PRINT" output from T-SQL

When I write stored procedures I often throw in a few print statements to help me understand what is going on. For example, if I have a routine that loops through table A and updates table B based on some conditions, I might include a print statement that said something like PRINT 'Condition Met' or PRINT 'Condition Not Met'. I could also output the values of a column or 2 to indicate why a condition was or was not met. That's a neat trick in Query analyzer and it makes debugging stored procedures easier. When you move the procedure to CF the PRINT output is lost or ignored. That is usually exactly what you want. But what if you did want to see the PRINT output? Is there a Coldfusion way to do id? Thanks to this great tip from Shlomy Gantz you can!

Read More
  • Share: