Save csv file as PHP attachment file + Apache installation doesn't work

I have an interesting problem which I think is server related. I want the CSV data to be saved as a CSV file when the user clicks a button. It works fine on my development server, but in production it just sends content to the page. I'm guessing this is a server issue, but I'm really not sure what it might be. Could GZIP affect this?

My header code looks like this:

header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Length: " . strlen($out));
header("Content-type: text/x-csv");
header("Content-Disposition: attachment; filename=$filename");
echo $out;

      

So this code above is running on a development server and in its production only CSV will be displayed on the page. Any ideas?

0


source to share


3 answers


The only thing I can think of is the mime type. I had problems with mime types (especially .flv files) when moving from one server to another.

What I used to CSV file application/octet-stream

.



Hope it helps

+1


source


Yes, I would guess that this is also a mime-type. You might want to try the special "text / csv" csv ( RFC 4180 ) or generic "application / octet-stream".



0


source


Just use Wireshark ( http://www.wireshark.org ) and grab HTTP traffic for both and look for differences. Fiddler should also work

0


source







All Articles