[Zope] Content Disposition - Download files

Dieter Maurer dieter at handshake.de
Mon Jun 26 14:55:29 EDT 2006


Bruno Grampa wrote at 2006-6-26 12:46 +0200:
>i want to send an image or a pdf  to a browser not for viewing but for
>downloading.
>I've written this code:
><dtml-call "RESPONSE.setHeader('Content-type',
>'application/force-download')">
><dtml-call "RESPONSE.setHeader('Content-Disposition', 'attachment;
>filename=filename.gif')">

You add an additional '<dtml-var "index_html(REQUEST, RESPONSE)">'

It might be necessary to avoid white space around your tags.
Therefore, it is better to do this in a Python Script
rather than a DTML object.

There, it would look like:

       r = container.REQUEST; R = r.RESPONSE
       R.setHeader(...) # your additional headers
       ...
       return context.index_html(r, R)

-- 
Dieter


More information about the Zope mailing list