HTTP Headers to make a download

Michael Foord fuzzyman at
Tue Oct 12 11:56:18 EDT 2004

I'm creating a CGI that offers files for download. After googling I
though I had the right headers to send to force a download - but it
sends the data to the browser instead of opening the download 'save
file' dialog. Can anyone see what I'm doing wrong/suggest an
alternative ?

responseline = '''Content-Type: application/octet-stream
Content-Disposition: attachment; filename=%s
Content-Length: %s

print responseline % (filename, len(filedata))
print filedata



More information about the Python-list mailing list