B
Bob Murdoch
I am sending an attachment to a user with the following code. This
successfully prompts the user to Save or Open, provides the correct file
name, and displays "Microsoft Excel Worksheet" as the Type.
However, when the user clicks "Save", the "Save As File Type" in the
resulting dialog displays 'HTML Document'. There is only one other entry in
the list - "All Files". How can I modify the code to display "Excel
Document" (or some such) in the "Save As Type" list?
thanks,
Bob M..
var vPath = Server.MapPath('/server/files') + '\\';
Response.AddHeader('Content-Disposition','attachment;filename=' +
Request('FileName') + ';');
var vType = 'application/octetstream';
var vFileName = String(Request('FileName')).toLowerCase();
if (vFileName.indexOf('.') > -1)
vType = 'application/vnd.ms-excel';
else if (vFileName.indexOf('.pdf') > -1)
vType = 'application/pdf';
else if (vFileName.indexOf('.zip') > -1)
vType = 'application/zip';
else if (vFileName.indexOf('.doc') > -1)
vType = 'application/vnd.msword';
Response.AddHeader('Content-Type', vType);
Response.AddHeader('Pragma','no-cache');
Response.AddHeader('Expires','0');
var vStream = Server.CreateObject("ADODB.Stream");
vStream.Open();
vStream.Type = 1; //binary
vStream.LoadFromFile(vPath + Request('TempFile')); //must be full server
path and file name
Response.BinaryWrite(vStream.Read());
vStream.Close;
vStream = null;
Response.End;
successfully prompts the user to Save or Open, provides the correct file
name, and displays "Microsoft Excel Worksheet" as the Type.
However, when the user clicks "Save", the "Save As File Type" in the
resulting dialog displays 'HTML Document'. There is only one other entry in
the list - "All Files". How can I modify the code to display "Excel
Document" (or some such) in the "Save As Type" list?
thanks,
Bob M..
var vPath = Server.MapPath('/server/files') + '\\';
Response.AddHeader('Content-Disposition','attachment;filename=' +
Request('FileName') + ';');
var vType = 'application/octetstream';
var vFileName = String(Request('FileName')).toLowerCase();
if (vFileName.indexOf('.') > -1)
vType = 'application/vnd.ms-excel';
else if (vFileName.indexOf('.pdf') > -1)
vType = 'application/pdf';
else if (vFileName.indexOf('.zip') > -1)
vType = 'application/zip';
else if (vFileName.indexOf('.doc') > -1)
vType = 'application/vnd.msword';
Response.AddHeader('Content-Type', vType);
Response.AddHeader('Pragma','no-cache');
Response.AddHeader('Expires','0');
var vStream = Server.CreateObject("ADODB.Stream");
vStream.Open();
vStream.Type = 1; //binary
vStream.LoadFromFile(vPath + Request('TempFile')); //must be full server
path and file name
Response.BinaryWrite(vStream.Read());
vStream.Close;
vStream = null;
Response.End;