Notice! This document is currently in
Archived
status.
The content of this document may be incorrect or outdated.
The content of this document may be incorrect or outdated.
Print this article Edit this article
Setting the filename for generated files for download
Purpose
When creating dynamically generated output, you may want to set the default filename which will be provided if the file is saved. This example shows how to specify the default filename used in the "Save file as" dialog box.
From a Python Script
filename = 'MySpecifiedFilename.txt' RESPONSE.setHeader('Content-Disposition', 'attachment; filename=%s' % (filename));From DTML
&lt;dtml-call &quot;RESPONSE.setHeader(&#39;Content-Disposition&#39;, &#39;attachment; filename=MySpecifiedFilname.txt&#39;)&quot;&gt;<br />Additional Notes
Additionally, you may wish to force the browser to prompt to save the file. Dependent on the configuration of the client browser, the save dialog box will appear with the name of the file set as above. You can do that by setting the following header:
RESPONSE.setHeader(&#39;Content-Type&#39;, &#39;application/force-download&#39;);<br />
Last Modified:
Aug 1, 2023 4:07 pm GMT-4
Created:
Mar 22, 2007 4:32 pm GMT-4
by
admin
JumpURL: https://eng.purdue.edu/jump/4b98b
Categories
- Knowledge Base > Web > Zope
- Knowledge Base > Web > Zope > Programming