PDA

View Full Version : Content-type: application/binary and setting file name


H-street
11-25-2002, 10:42 PM
Is there a way to set the file name of a save as file instead of it reading .CGI document?


i have a CGI that is exporting custom XML from a database and i have it working but it bothers me that when it pops up the Save As dialogue it always says

CGI Document

and if you type say


TEST.XML it will save it ias TEST.XML.CGI..

is there a way to force the extention using the Header? or even set a recommended file name..

IE. Set it so when it pops up the Save As dialogue it will save

Save As..
Query.XML

XML Document


keep in mind that temporary files are out of the question as simultaneous users could overwrite the same file.. and i don't think i want to start dealing with keeping unique session_ids just so they have a file name.

chrisvmarle
11-26-2002, 03:16 PM
Maybe this will help, it's all I could find...

It's from an old download.cgi file I used once

print "Content-type: application/download\n";
print "Content-length: $file_size\n";
print "Content-transfer-encodig: binary\n";
print "Content-disposition: attachment; filename=$file\n\n";

Mzzl, Chris