Have installed a Turnkey LAMP appliance and new server up and running with our internal customer system written in PHP using MySQL in no time.
However, all of our screens that force a download of a file, .ics calendar files and .vcf vcard files have now stopped working and simply display in the browser.
I know the coding works, as it worked in our old standard Unbuntu LAMP setup, works if I simply move it to a MAMP system, and works fine if I move it to any commercial LAMP hosting, such as Hostgator.
Since it worked before and works anywhere other than the Turnkey LAMP service, it means that the Turnkey LAMP has something in it's default setup that is not like anyone elses default setup. I've also tried changing my PHP code to everything suggested on the net, but nothing changes.
Given that I can move the same code literally anywhere else and it works fine, I need to find the answer quickly, as it's a real pain that it doesn't work, our staff rely on these features.
The code is very simple and is below and as I said before I get too many suggestions that the code is wrong, this code runs on any other server I use quite happily and basically makes the browser download an ics calendar file which the user can then double click on to add into their calendar. The only place is doesn't work is on the Turnkey LAMP. Therefore, must be a non-standard setting somewhere on Turnkey which is doing this, however have no idea where.
No combination of changing the file types makes any difference.
$filename = 'job-' . $job_number . '.ics';
$mimeType = 'application/ics';
header('Content-Type: ' . $mimeType);
header('Content-Disposition: attachment; filename=' . $filename);
if ($address2) $addressline = $addressline . ", " . $address2;
if ($address3) $addressline = $addressline . ", " . $address3;
if ($address4) $addressline = $addressline . ", " . $address4;
if ($town) $addressline = $addressline . ", " . $town;
if ($county) $addressline = $addressline . ", " . $county;
if ($postcode) $addressline = $addressline . ", " . $postcode;
if ($name_company) $name_company = " [" . $name_company . "]";
$phoneline = "";
if ($tel_work) $phoneline = $phoneline . "Work: " . $tel_work . "\r";
if ($tel_home) $phoneline = $phoneline . "Home: " . $tel_home . "\r";
if ($tel_mobile) $phoneline = $phoneline . "Mobile: " . $tel_mobile . "\r";
$emailline = "\r";
if ($email) $emailline = "Email: " . $email . "\r";
//replace newlines with carriage returns so ical picks them up ok
$desc = str_ireplace ( "\n", "", $work_expected);
echo "SUMMARY:Job $job_number [$job_type_desc] - $name_first $name_last $name_company\n";