Jump to content

Recommended Posts

The download doesn't start and nothing appears on the screen. This happens in IE and Firefox.

 

header("Content-type: text/plain");
header('Content-Disposition: inline; filename=$file_name.csv');
echo $data; 

 

The data and file name is created before. I have tried a number a bunch of different things with the header, but it is not working. I don't get it....

 

I also tried this:

header('Pragma: no-cache');
header('Expires: 0');
header('Content-Type: text/x-csv');
header('Content-Disposition: attachment; filename=$file_name.csv');
header("Content-Transfer-Encoding: binary");
echo $data; 

this has worked for me

 

<?php
$filename = 'xyz.csv';

header('Content-type: application/octet-stream');
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past

echo "A, 1, 2, 3\n";
echo "B, 4, 5, 6\n"; 

I tried:

<?php
$filename = 'xyz.csv';

header('Content-type: application/octet-stream');
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past

echo "A, 1, 2, 3\n";
echo "B, 4, 5, 6\n"; 

 

Now it works in firefox, but in IE it outputs to the browser rather than start a download.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.