0
click link and download file

/t5/coldfusion-discussions/click-link-and-download-file/td-p/438770
Nov 02, 2007
Nov 02, 2007
Copy link to clipboard
Copied
Hi ,
I am creating xml file from query and then read xml file as pdf using cf document.
So I have my list in the website as xml file and pdfs So if click on xml it should ask me for download/save as and same thing for pdf. How can I do that. I know cfcontent but it doesn't work
I am creating xml file from query and then read xml file as pdf using cf document.
So I have my list in the website as xml file and pdfs So if click on xml it should ask me for download/save as and same thing for pdf. How can I do that. I know cfcontent but it doesn't work
TOPICS
Advanced techniques
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explorer
,
/t5/coldfusion-discussions/click-link-and-download-file/m-p/438771#M39649
Nov 04, 2007
Nov 04, 2007
Copy link to clipboard
Copied
You can try below code for your XML file.
<cfheader name="content-disposition" value="attachment; filename = #trim(filename)#">
<cfcontent type="text/xml; charset=utf-8" file="#absolutefilepath#">
If it doesn't work, then try below one :D
<cfoutput>
<cfheader name="content-disposition" value="attachment; filename = #trim(filename)#">
<cfcontent type="text/xml;">
<cffile action="READ" file="#absolutefilepath#" variable="content" charset="iso-8859-1">
#trim(content)#
</cfoutput>
<cfheader name="content-disposition" value="attachment; filename = #trim(filename)#">
<cfcontent type="text/xml; charset=utf-8" file="#absolutefilepath#">
If it doesn't work, then try below one :D
<cfoutput>
<cfheader name="content-disposition" value="attachment; filename = #trim(filename)#">
<cfcontent type="text/xml;">
<cffile action="READ" file="#absolutefilepath#" variable="content" charset="iso-8859-1">
#trim(content)#
</cfoutput>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
New Here
,
/t5/coldfusion-discussions/click-link-and-download-file/m-p/438772#M39650
Nov 06, 2007
Nov 06, 2007
Copy link to clipboard
Copied
here is how I have always done this. I create a file called
download.cfm. In that file I simply put this code
<cfsetting enablecfoutputonly="yes">
<cfheader name="Content-disposition" value="attachment; filename=""#Url.FileName#""">
<cfcontent type = "foo/bar" file = "/path_to_the_file/#Url.FileName#">
Now I pass the FileName through the Url and it WILL ask if you want to open or download the file. We accomplish this by making up an eronious file type.
<cfsetting enablecfoutputonly="yes">
<cfheader name="Content-disposition" value="attachment; filename=""#Url.FileName#""">
<cfcontent type = "foo/bar" file = "/path_to_the_file/#Url.FileName#">
Now I pass the FileName through the Url and it WILL ask if you want to open or download the file. We accomplish this by making up an eronious file type.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explorer
,
/t5/coldfusion-discussions/click-link-and-download-file/m-p/438773#M39651
Nov 07, 2007
Nov 07, 2007
Copy link to clipboard
Copied
Just to call attention to something for Tiono:
Note the quotes around the filename= parameter in Duke Snyder's code:
<cfheader name="Content-disposition" value="attachment; filename=""#Url.FileName#""">
(although I make mine easier to read by mixing single and double quotes as in:
<cfheader name="Content-disposition" value='attachment; filename="#Url.FileName#"'>
if you don't surround the file name with quotes, you'll have trouble downloading files with spaces in the name. And the quotes need to be double quotes.
Note the quotes around the filename= parameter in Duke Snyder's code:
<cfheader name="Content-disposition" value="attachment; filename=""#Url.FileName#""">
(although I make mine easier to read by mixing single and double quotes as in:
<cfheader name="Content-disposition" value='attachment; filename="#Url.FileName#"'>
if you don't surround the file name with quotes, you'll have trouble downloading files with spaces in the name. And the quotes need to be double quotes.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explorer
,
/t5/coldfusion-discussions/click-link-and-download-file/m-p/438774#M39652
Nov 07, 2007
Nov 07, 2007
Copy link to clipboard
Copied
wow, thanks man. I didn't know about that quote things :D
so far never use filename with spaces hehehe.
so far never use filename with spaces hehehe.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explorer
,
LATEST
/t5/coldfusion-discussions/click-link-and-download-file/m-p/438775#M39653
Nov 08, 2007
Nov 08, 2007
Copy link to clipboard
Copied
If you have total control over your own system, you can
disallow spaces, but if you have to allow "the public" to upload
files, you have to be able to handle it.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

