Solved

Opening a file using cfheader/cfcontent

Posted on 2001-07-08
5
1,133 Views
Last Modified: 2013-12-24
Hi

I am having trouble with opening a file using cfcontent.  The filename presented in the open/save dialog is the name of the cfm page.  I have tried using a cfheader, but that does not help either:

<CFHEADER NAME="Content-disposition" value="attachment; filename=#MyFile#">
<CFCONTENT TYPE="unknown" DELETEFILE="No" FILENAME="#MyFile#">

I have also tried using the inline value for cfheader to no avail.

The file I want to open has the extension .jrp, and I want the file to open the associated application using the filename as a parameter.  I have registered the filetype .jrp in windows explorer.

What am I doing wrong?

Regards
John
0
Comment
Question by:jdthedj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
CF_Spike earned 100 total points
ID: 6263231
Here is an example which should work and ought to point you in the right direction:

Create a file called test.jrp

In the same directory create two cfm files - index.cfm and download.cfm. The code for these two files is below:

index.cfm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
     <title>cfcontent</title>
</head>

<body>
<A HREF="download.cfm">force download</A>
             
           

</body>
</html>


download.cfm

<CFSET filename = "test.jrp">
<CFSET fullpath = "C:\InetPub\wwwroot\test.jrp">

<cfheader name="Content-Disposition" value="attachment; #variables.filename#">
<CFCONTENT TYPE="text/plain"
           FILE="#variables.fullpath#"
           DELETEFILE="No">

Browse to index.cfm and click the link. You should be prompted to save test.jrp. You can change this filename in any way you want to make it dynamic, but you will need to make sure that you use the full path with cfcontent.

Spike
0
 
LVL 3

Author Comment

by:jdthedj
ID: 6263304
Hi Spike

Thanks for the reply.  I have done what you have suggested, but the dialog is still coming up with "You have chosen to download a file from this location download.cfm from Server"

Any ideas?

John
0
 
LVL 3

Author Comment

by:jdthedj
ID: 6263826
Hello again Spike - I persevered with the code you gave me, and it works with inline instead of attachment.

Thanks for your help

John
0
 

Expert Comment

by:frostino
ID: 33420215
Neither inline or attachment worked me for.  I still get the dialog box with the default filename of download.cfm .

I use the following code on the download.cfm page and I'm passing a URL param from another page because I have multiple files to download.  All files are in the same directory as the download.cfm so the path is basically the filename.


<cfheader name="Content-Disposition" value="attachment; #url.download#">
<CFCONTENT TYPE="audio/mpeg"
           FILE="#url.download#"
           DELETEFILE="No">

Open in new window

0
 

Expert Comment

by:frostino
ID: 33420300
Nevermind, I realized I was missing "filename" after "attachment;"
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question