Highlighted

How can I make the browser use the proper filename during a forced save, using CFCONTENT/CFHEADER

Engaged ,
Feb 27, 2015

Copy link to clipboard

Copied

We have a client using CF8 Server for a site and I am using the CFHEADER/CFCONTENT method to force a file to save to the end-user's computer.

The dialogue comes up as expected, but regardless of what is found in the CFHEADER for a filename, it tries to save the file as the CFM page name.

i.e. The CFM page is signature.cfm. I am trying to make it save a TXT file to the user's computer, which it seems to be trying to do, but the instead of using "sig.txt" as the filename as outlined in the CFHEADER, it is defaulting to "signature.cfm"

While I know that I could change the name and extension and the content in the file would be correct, the mass majority of end-users will not know that they can do that, and the client does not want it to become more complicated than necessary.

Is there a way to make the file change to the proper name in the SAVE AS dialogue?

Thanks in advance.

Code so far is pretty straight forward ...

<CFHEADER name="Content-Disposition" value="attachment; filename=sig.txt">

<CFCONTENT type="application/unknown" file="#xf#">

Views

173

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

How can I make the browser use the proper filename during a forced save, using CFCONTENT/CFHEADER

Engaged ,
Feb 27, 2015

Copy link to clipboard

Copied

We have a client using CF8 Server for a site and I am using the CFHEADER/CFCONTENT method to force a file to save to the end-user's computer.

The dialogue comes up as expected, but regardless of what is found in the CFHEADER for a filename, it tries to save the file as the CFM page name.

i.e. The CFM page is signature.cfm. I am trying to make it save a TXT file to the user's computer, which it seems to be trying to do, but the instead of using "sig.txt" as the filename as outlined in the CFHEADER, it is defaulting to "signature.cfm"

While I know that I could change the name and extension and the content in the file would be correct, the mass majority of end-users will not know that they can do that, and the client does not want it to become more complicated than necessary.

Is there a way to make the file change to the proper name in the SAVE AS dialogue?

Thanks in advance.

Code so far is pretty straight forward ...

<CFHEADER name="Content-Disposition" value="attachment; filename=sig.txt">

<CFCONTENT type="application/unknown" file="#xf#">

Views

174

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Feb 27, 2015 0
Advocate ,
Feb 27, 2015

Copy link to clipboard

Copied

I'm guessing the type="application/unknown" is interfering. Try type="text/plain".

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 27, 2015 0