Web :: Browser issues :: How to prevent Excel files from opening in browser? |
|||
| By: YBYM |
Date: 03/10/2003 00:00:00 |
Points: 125 | Status: Answered Quality : Excellent |
|
I'm working on an Intranet portal written in ASP. I'm providing a list of file names as hrefs for users to select from (file://server/share/path/file.ext) If the user selects an Excel file, it is opening in the browser and confusing the heck out of the user. How can I force the Open/Save dialog when the user clicks on a link, mimicking the functionality of the right click 'Save Target As' menu item? Two solutions that I have seem are not possible for me - the first is to set the header of the page being returned from my ASP script to indicate that the file is an attachment. These files are not located on the web server, but on different file servers throughout the company. I am simply providing a central list of them. The second solution is to modify the mime type for xls on the users machine, which is not possible due to operational considerations. tia, Bob M.. |
|||
| By: ExcelRay | Date: 03/10/2003 14:23:00 | Type : Comment |
|
| In your scenario, you will need to make a change on the client machines. The change is: Windows Explorer: Tools(View if NT) - Folder Options - File Types - XLS file extension (Excel workbook if NT) Browse in same window = FALSE Confirm open after download = TRUE Ray at home |
|||
| By: VGR | Date: 03/10/2003 16:02:00 | Type : Comment |
|
| easy. you've to send, not the MIME-type (content-type) HTTP header of type "application/ms-excel" but one of the two [usually one works] : "application/save" or "application/octetstream" like in : header("Content-disposition: attachment;;filename=$filename.txt"); header("Content-type: application/octetstream"); // or application/save header("Pragma: no-cache"); header("Expires: 0"); $client=getenv("HTTP_USER_AGENT"); $fp=fopen("$filename","r"); $str=fread($fp,filesize($filename)); echo $str; fclose($fp); |
|||
| By: YBYM | Date: 04/10/2003 23:03:00 | Type : Comment |
|
| ExcelRay, >>In your scenario, you will need to make a change on the client machines Unfortunately, I have no power to enforce a change of configuration on the client machines, so this avenue is closed to me. VGR, >>easy. you've to send, not the MIME-type (content-type) HTTP header of type "application/ms-excel" but one of the two [usually one works] : "application/save" or "application/octetstream" This looks like a solution that would be used if the files are located on the web server, which they are not. These files are located on various file servers, which require security credentials that the IIS server does not have. Additionally, I would like to keep the processing of these files off of the web server (some of them can be rather large). So the question is, how do I redirect the client to these files in such a way as to cause them to show the Open/Save, even if their browser is set to open internally? Is there no javascript command to invoke the Open/Save dialog in an OnClick event? tia, Bob M.. |
|||
| By: VGR | Date: 04/10/2003 23:46:00 | Type : Answer |
|
| no the "save as" dialog box on the client is triggered by its browser alone, when the mime type is unknown to it. Thus the "application/save" and "application/octetstream" tricks to fool him sorry... |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








