Welcome Guest, Not a member yet? Register   Sign In
Random problem with set_header()

I am having a random issue with Content-Disposition header not being sent from my controller, depending on the content.  Here is my controller function:

PHP Code:
public function download() {
        $this->output->set_header('Content-Disposition: attachment; filename="test.csv"');
        //header('Content-Disposition: attachment; filename="test.csv"');

If I un-comment the header() call, then it always works, but otherwise sometimes it works and sometimes not, seems to depend either on the content of /tmp/test.csv or else it is just plain random -- I have not been able to nail down any specific lines of content that consistently reproduce the issue.

It seems pretty simple but maybe I'm doing something wrong?

(This is CI 3.1.10, using PHP 7.3.11, with Apache 2.4 and modsecurity2)

I would use the built in force_download in Codeigniter for this: https://codeigniter.com/user_guide/helpe...elper.html

That works - and (bonus) I looked at the code for force_download() and it outputs in 1MB chunks so as to not overrun memory, which I was concerned about.

So thanks!

(But it would be nice to know what the heck is wrong with my example)

Theme © iAndrew 2016 - Forum software by © MyBB