Codeigniter Force download IE Codeigniter Force download IE codeigniter codeigniter

Codeigniter Force download IE


Frankly I am not sure why we bothered with a helper for downloads in code igniter.

It's not entirely hard to do in pure php:

This Wonderful Question/Answer outlines how to do it quite nicely.

The real thing to remember is the content-disposition: attachment part of the headers. It's what tells the browser that the file should be downloaded & saved vs. trying to show it in the browser.

All browsers handle things differently, maybe you have something in your IE install that's overriding the behaviour but if you follow the instructions in the linked article, you should get files downloaded correctly in all browsers.

Essentially there are 3 things we need to tell the browser:

  • Content Type
  • File Name
  • How to treat the incoming data
  • (Optional Fourth, if you have it) File Size (Content-Length)

Then you just dump that data right out to the output buffer.

Response

In response to your replies, it's probably a security feature to not automatically download something in a popup window, probably one of the new things IE introduced to combat their previous security holes.


Well I have found atleast a temporary fix for the problem. All my links for force downloads were target _blank..once I created standard non pop out links the file downloads worked in IE. There is probably some type of work around but I just also realized there is really no need for a pop up window for the download anyway..the download dialog box already serves that purpose.