I have a request that uses this url to download files from the site. It's the <a href= executed when the link on the page is clicked.
The DisplayReport method has this code:
lcExt = UPPER(JUSTEXT(lcFileName))
DO CASE
CASE lcExt = 'PDF'
Response.transmitfile(lcFileName, 'application/pdf')
CASE lcExt = 'DOC'
Response.transmitfile(lcFileName, 'application/msword')
CASE lcExt = 'DOCX'
Response.transmitfile(lcFileName, 'application/vnd.openxmlformats-officedocument.wordprocessingml.document ')
CASE lcExt = 'GIF'
Response.transmitfile(lcFileName, 'image/gif')
CASE lcExt = 'JPEG' OR lcExt = 'JPG'
Response.transmitfile(lcFileName, 'image/jpeg')
CASE lcExt = 'PNG'
Response.transmitfile(lcFileName, 'image/png')
CASE lcExt = 'BMP'
Response.transmitfile(lcFileName, 'image/bmp')
CASE lcExt = 'RTF'
Response.transmitfile(lcFileName, 'application/rtf')
CASE lcExt = 'TXT'
Response.transmitfile(lcFileName, 'text/plain')
CASE lcExt = 'XLS' OR lcExt = 'XLSX'
Response.transmitfile(lcFileName, 'application/msexcel')
CASE lcExt = 'XLSX'
Response.transmitfile(lcFileName, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet ')
OTHERWISE
response.transmitfile(lcFileName, 'text/plain')
ENDCASE
The probem I'm having is that when the file downloads, it has the displayreport.or filename instead of the actual filename. Is there a way to get it to respect the filename of the file being downloaded?
If I rename the file after it's downloaded it will open fine with Excel, Word or whatever the default application for the type is.
-Phil
Use Response.DownloadFile() instead. TransmitFile()
just sends the file, DownloadFile()
sends the required headers to force the filename.
+++ Rick ---
Perfect!
Just what I needed. I misunderstood RESPONSE.DOWNLOADFILE. I thought it would always give a "Save As" dialog when downloading the file. Looks like it only does that if you don't give it the file name to use.
Thanks!
-Phil