Welcome Guest, Not a member yet? Register   Sign In
How to not send "content-type"

[eluser]Ñuño Martínez[/eluser]
I wrote a controller to send the CSS file. In short, it's something like this:
class styles extends CI_Controller {

  public function _remap ($Metodo)
    $this->load->helper ('file');
    if ($Metodo == 'estilo.css' or $Metodo == 'estilo')
      echo read_file (DIR_TEMPLATE.'estilo.css');
    elseif ($Metodo == 'form.css' or $Metodo == 'form')
      echo read_file (DIR_TEMPLATE.'form.css');
      show_404 ($Metodo);
It works. I mean it returns the correct CSS code. The problem is that it includes 'Content-Type: "text/html; charset=..."' in the header so the browser doesn't recognizes it as CSS code, so it doesn't applies the styles to the document. I've tested it in Firefox and Midori (Webkit).

Is it possible to avoid the "Content-Type" header?

Maybe just set the correct mime type before you send the file out. If there isn't a mime type the browser won't know how to correctly interpret the file.
header("Content-type: text/css; charset: UTF-8");
echo read_file (DIR_TEMPLATE.'estilo.css');

[eluser]Ñuño Martínez[/eluser]
Thank-you very much. I was thinking about using "header" but I discarded it too soon... :red:

Theme © iAndrew 2016 - Forum software by © MyBB