IE is weird. Still, many people prefer to use IE. Recently I had an issue with csv file download. I have a program that downloads a set of data from the database in the form of csv file. If you click the download button, you will be prompted to open/save the csv file. All is well in firefox, safari and chrome. When I test this in IE, it bombs and throws error message “Internet explorer can’t contact the site….”
The page I was testing was on the https site. It also use session variables. For some reasons IE goes haywire when it looks at session variables, https and file download request combo. After banging my head on the wall for few minutes, I found the blog written by Joseph Scott. Joseph listed the ways to fix this issue. However, that didn’t work for me.
Fortunately lots of users pitched in and left their comments about what really worked for them. I tried all of them in sequence, nothing seems to be working. One of the users, Duncan, posted the code to check for IE and execute different header commands. Following is the working code.
header('Content-Disposition: attachment; filename=filenamegoeshere.csv');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
//Now echo the content of csv file
We basically force IE to download the file from server instead of cache. That did the trick and IE behaved.
- Infosys in hot water
- Google +