TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
htmlspecialchars error on Image::factory
  • I am getting a strange error in Kohana. The if block on this code works


    $width = Arr::get($_GET, 'w', FALSE);
    $height = Arr::get($_GET, 'h', FALSE);

    $type = $this->request->param('type');
    $file = $this->request->param('file');

    $temp = DOCROOT.'uploads/'.$type .'/' .$file;

    if (file_exists($temp))
    {
    $image = Image::factory($temp);

    if ($width && $height)
    {
    $image->resize($width, $height, Image::NONE);
    }
    }
    else
    {
    $type = 'item';
    $file = '70_20080411121920jzy.jpg';
    $url = DOCROOT.'uploads/' . $type .'/' . $file;
    $image = Image::factory($url);
    }


    But the else block produces a

    ErrorException [ 2 ]: htmlspecialchars(): Invalid multibyte sequence in argument ~ SYSPATH/classes/kohana/core.php [ 1123 ]

    The url looks like this: http://df2.com/image/item/Zeb_Andrews7.jpg?h=179&w=134

    This is quite strange to me because the error does not appear in the if block. However, the if block gets it params from $this->request->param while the params are manually supplied to the else block. Did I miss something here?