I have to make a php-generated file to be downloadable, not openable in browser. While it is small (1-2 kb) file saves normally in Downloads, but after some point, Chrome starts opening it instead of downloading.
Here is controller's code:
public function download($format, $str)
{
$get_string = rawurldecode($str);
parse_str($get_string, $get_array);
$webinar_id = $get_array['webinar_id'];
unset($get_array['webinar_id']);
$date = new DateTime();
$this->output->set_header('Content-type: text/plain');
$this->output->set_header('Content-Disposition: attachment; filename=Segmentation ' . $date->format('Y-m-d H:i:s') . '.' . $format);
if (! empty($get_array))
{
echo $this->segmentation_model->do_query($webinar_id, $get_array, $format);
}
}