CodeIgniter Forums
cannot modify headers bug? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: cannot modify headers bug? (/thread-52736.html)



cannot modify headers bug? - El Forum - 06-24-2012

[eluser]superfake123[/eluser]
Hello, I keep getting the following error / warning

Code:
ERROR - 2012-06-24 20:16:07 --> Severity: Warning  --> Cannot modify header information - headers already sent by (output started at /home/user/public_html/html_project/system/application/models/admin_model.php:173) /home/user/public_html/html_project/system/core/Output.php 92


line 173 of admin_model is:

Code:
imagejpeg($image,"",80);


Should I not be using that?



Thanks..


cannot modify headers bug? - El Forum - 06-24-2012

[eluser]PhilTem[/eluser]
It looks like you create an error with the second argument you provide for imagejpg. I think what you need to know (from the PHP Doc)

Quote:Parameters:
filename:
The path to save the file to. If not set or NULL, the raw image stream will be outputted directly.

To skip this argument in order to provide the quality parameter, use NULL.

Try setting the second parameter to NULL and see what happens^^


cannot modify headers bug? - El Forum - 06-24-2012

[eluser]superfake123[/eluser]
nope, it still does it D:

This started after I added to the admin controller construct:

Code:
$this->output->set_header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");
$this->output->set_header("Cache-Control: post-check=0, pre-check=0", false);
$this->output->set_header("Pragma: no-cache");

I was having issues in IE not reloading any changes made in the admin panel so I needed to add the above. I'm not sure how to fix this :\


cannot modify headers bug? - El Forum - 06-24-2012

[eluser]superfake123[/eluser]
still happening D:

here is the entire function that is causing the warning

Code:
public function slideshow_thumb($img, $maxDim, $location)
{
  $location = str_replace('-', '/', $location);
  list($curImgW, $curImgH) = getimagesize('images/'.$location.'/'.$img);

  if($curImgH > $curImgW)
  {
   $dif = $maxDim/$curImgH;
   $newH = $maxDim;
   $newW = floor($curImgW*$dif);
  }
  else
  {
   $dif = $maxDim/$curImgW;
   $newW = $maxDim;
   $newH = floor($curImgH*$dif);
  }

  ini_set('memory_limit','128M');
  $startImg = imagecreatefromjpeg('images/'.$location.'/'.$img);
  $image = imagecreatetruecolor($newW, $newH);

  imagecopyresampled($image, $startImg, 0, 0, 0, 0, $newW, $newH, $curImgW, $curImgH);
  imagejpeg($image, NULL, 80);
  imagedestroy($startImg);
  imagedestroy($image);

}



cannot modify headers bug? - El Forum - 06-25-2012

[eluser]superfake123[/eluser]
sorry, bump! anyone?


cannot modify headers bug? - El Forum - 06-25-2012

[eluser]CroNiX[/eluser]
The problem could probably be that you are outputting the image (via imagejpeg) before the headers are sent along with the rest of the final output from the controller. Try returning your image and outputting it from your controller with the rest of your data so it gets buffered with the rest of the content.