Skip to main content
Participant
July 3, 2008
Question

download and redirect to another page

  • July 3, 2008
  • 2 replies
  • 641 views
I used the following code to download a pdf file (download.cfm) but the current page becomes blank. I want it to change to another page (view.cfm) using self.location but without success

view.cfm
<cfdirectory
directory="/var/www/html/"
action="list"
filter="*.pdf"
name="fax">
<cfoutput query="fax">
<a href="download.cfm?filename=#fax.name#">#fax.name#</a><br>
</cfoutput>


download.cfm
<cfheader name="Content-Disposition" value="inline; filename=#url.filename#">
<cfcontent type="application/pdf" file="/var/www/html/#url.filename#">
<script>
self.location="view.cfm";
</script>

pls kindly advise.
    This topic has been closed for replies.

    2 replies

    Participating Frequently
    July 3, 2008
    You can't do what you're trying to do. <cfcontent file="..."> stops processing of the page.

    http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_c_11.html#2850760
    And the description next to the file attribute includes:
    "When you use this attribute, any other output on the current CFML page is ignored; only the contents of the file are sent to the client."

    Why not just have the download.cfm link open in a new window? target="_blank"
    Inspiring
    July 3, 2008
    have you tried <cflocation url="view.cfm"> ?