Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

application.cfm & .xls question

Status
Not open for further replies.

okiiyama

IS-IT--Management
Jan 3, 2003
269
US
Is it possible to have Coldfusion process the application.cfm page in a directory when the URL is for an .xls (or any other filetype for that matter).

Example: In the directory: "stuff" there are 2 files
1. application.cfm which performs a permissions check
2. test.xls

if someone types in the url: I would like the application.cfm page to execute. Would there be a setting to change in the CF Admin, or is this not possible?

Thanks
 
Application.cfm only applies to ColdFusion pages. The only way to do this would be to link to a cfm page that then pulls or redirects to the .xls file.


Hope This Helps!

ECAR
ECAR Technologies

"My work is a game, a very serious game." - M.C. Escher
 
You can do this by creating a file called "xxxx.cfm" with the following:

Code:
<HTML><HEAD>
<meta HTTP-EQUIV="Refresh" CONTENT="0; URL=http://www.test.com/stuff/test.xls">
</HEAD><BODY>&nbsp;</BODY></HTML>

That way your application.cfm file will check the perms and redirect. The problem with this of course is that you then still expose the URL to your .XLS file....

If you really want security (and don't want to or can't use OS level security) what I've done in the past if have a little routine that copies the file somewhere, renames it with a GUID file name and then displays it. I then have a scheduled job (every 5 minutes or so) that basically just deletes all the files in that directory (the GUID file name copies of your .XLS file). That way people never see the location or name of your real file and "guessing" the file name is next to impossible---and even if someone could guess it the name would only be valid during the timeframe of your "delete the files" scheduled job....

Here's some example code to get you started:

Code:
	<cfset filename="#createuuid()#-#(rand()*100000000)#.xls">

        <CFFILE ACTION="Copy" SOURCE="c:\inetpub\[URL unfurl="true"]wwwroot\Reports\YOUR_EXCEL_FILE.xls"[/URL] DESTINATION="c:\inetpub\[URL unfurl="true"]wwwroot\Reports\Output\#filename#">[/URL]

	<center><cfoutput><a href="[URL unfurl="true"]http://YOUR_URL/Reports/Output/#filename#"[/URL] onMouseOver="window.status='Click here to view the file YOUR_EXCEL_FILE.xls '; return true;"><img src="XLSicon.gif" border="0" align="absmiddle" hspace="5"><font size="3"><b>View File*</b></font></cfoutput></a></center><br>

	<center><font size="1">* This document will be available for approximately 15 minutes.</font></center><br><br><br>
 
just use cfcontent to server the file. run any logic you need before the cfcontent tag.

you can pull the file from below the web root if wanted, so direct access is impossible (if you want).



Kevin

Phase 1: Read the CFML Reference
Phase 2: ???
Phase 3: Profit!
 
you can even use cfheader to give the file a specific name during the download

<cfheader name="Content-Disposition" value="attachment;filename=whateverFileNameYouWant.xls">


Kevin

Phase 1: Read the CFML Reference
Phase 2: ???
Phase 3: Profit!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top