
For starters, CFLocation can only point to publicly accessible folders.

Now, this example uses a CFLocation to forward the user to a given file. I am capturing the full file name, but it sounds like you have a good document ID to grab - you would use that instead as IDs are just about always better to use than file names (which might change). ColdFusion will automatically decode URL values for us (as far as I know).Īfter clicking around on the links, here is what our download_log.txt file looks like: Also notice that we do not decode the file name on the proxy page. This is the safe thing to do since we never know what kind of crazy characters there are in the file names. Notice that we are URL encoding our file names. Now that we have our proxy.cfm ColdFusion template in place, we have to go back and alter our links to point to the proxy template rather than directly to the files: If you your files are in specific directories, then you will probably have to alter the ColdFusion CFLocation tag: This demo assumes that all the files are in a known, web-accessible directory. This is the name of the file that the user wants to download. Here is the code for the proxy.cfm ColdFusion template.


For this demo, I am logging the document requests to a text file, "download_log.txt," but this could just as easily be a database or an XML file or what ever kind of data persistence model you like. In order to track the downloads for a particular file, I will either route the file download through a proxy that logs the document activity and then forwards the user to the requested file or I will use a mouse event tracker like you mentioned. These three method discussed below are variations on things that I have done - each has its time and place. I'm not proficient in cfc's and cfscript, so if you can give me an example I can modify, I'd be greatful.įirst, let me tell you that I don't know what the best solution is. My thought was to have the href link to the doc include an onclick event, which calls a function which would do an sql insert, adding the userID, docID and date to the database. What I'd like to do is to record when someone downloads a doc. In a nutshell, I have a library application that allows people to download docs once they've logged in. I have been snooping around various CF resources, and haven't seen anything close to what I'm trying to do. I am working on a project that includes a little function that I am having trouble with.
