samedi 28 mai 2016

laravel5 did not show php image in controller or route

I use laravel with version 5.1.35, but i found it not show image which write by php raw code. The code in raw php is

header("Content-type: image/png");
$im = @imagecreate(200, 50) or die("create php image rs error");
imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 0, 0, 255);
imagestring($im, 5, 0, 0, "Hello world!", $text_color);
imagepng($im);
imagedestroy($im);

output of php is hello world

but in laravel 5.1.35 in route define is

Route::get('png',function(){
//  echo \Image::make(public_path('assets/image/xundu/logo.jpg'))->response('png');
    header("Content-type: image/png");
    $im = @imagecreate(200, 50) or die("create php image rs error");
    imagecolorallocate($im, 255, 255, 255);
    $text_color = imagecolorallocate($im, 0, 0, 255);
    imagestring($im, 5, 0, 0, "Hello world!", $text_color);
    imagepng($im);
    imagedestroy($im);
});

Output of it is php raw code display in laravel



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire