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

[eluser]Ñuño Martínez[/eluser]
I wrote a controller to send the CSS file. In short, it's something like this:
Code:
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');
    else
      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?
#2

[eluser]CroNiX[/eluser]
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.
Code:
header("Content-type: text/css; charset: UTF-8");
echo read_file (DIR_TEMPLATE.'estilo.css');
#3

[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