Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Opening a file using cfheader/cfcontent

Posted on 2001-07-08
5
Medium Priority
?
1,169 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
  • 2
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
CF_Spike earned 400 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

877 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