Hey Guys,
I have an excel (xls) file living on a server that I'm trying to download via
flex with a FileReference. I'm having a hard time setting the MIME type. The
"Save as type" drop down in the browsers file download dialog is always blank
in IE, and is set to All Files (*) in Firefox but will never say "Microsoft
Excel File...". Below is the code I'm using.
var fileLocation:String = "/whatever/file.xls";
var fileName:String =
String(fileLocation.split('/')[fileLocation.split('/').length - 1]);
var request:URLRequest = new URLRequest();
request.url = fileLocation;
request.contentType = "application/vnd.ms-excel";
request.requestHeaders.push(new URLRequestHeader( "Content-Disposition",
"attachment; filename=" + fileName ));
request.requestHeaders.push(new URLRequestHeader( "Content-Type",
"application/vnd.ms-excel" )) ;
var downloadFileRef:FileReference = new FileReference();
downloadFileRef.download(request, fileName);
Let me know if anyone has any ideas.
Thanks!