Solved

Opening a file using cfheader/cfcontent

Posted on 2001-07-08
5
1,110 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 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Restrict IIS Website without Windows login 7 58
Forbidden errors 5 152
Web server load balancing technologies and methods 3 96
app server have enough resources... 2 52
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

828 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