I don’t know where I’ve got a mistake, when I fire below code from http://localhost/image.php?application=first everything is OK.
session_start();
$name = $_GET['application'];
$text = rand(10000,99999);
$_SESSION['application'][$name] = $text;
$height = 25;
$width = 65;
$image_p = imagecreate($width, $height);
$black = imagecolorallocate($image_p, 0, 0, 0);
$white = imagecolorallocate($image_p, 255, 255, 255);
$font_size = 14;
imagestring($image_p, $font_size, 5, 5, $text, $white);
imagejpeg($image_p, null, 80);
but when I changed code for this
if (isset($_GET['application']) && !empty($_GET['application'])) {
if (isset($_GET['image']) && $_GET['image'] == 'get'){
session_start();
$name = $_GET['application'];
$text = rand(10000,99999);
$_SESSION['application'][$name] = $text;
$height = 25;
$width = 65;
$image_p = imagecreate($width, $height);
$black = imagecolorallocate($image_p, 0, 0, 0);
$white = imagecolorallocate($image_p, 255, 255, 255);
$font_size = 14;
imagestring($image_p, $font_size, 5, 5, $text, $white);
imagejpeg($image_p, null, 80);
}
}
then I get RAW format in browser, so I add
header('Content-type: image/jpeg');
imagejpeg($image_p, null, 80);
to the code, and now I’ve get message, that my picture is interrupted, but when I save it on drive and launch from IrfanView it opens normally.
I would like to add that I was testing ob_start() function, but it didn’t change anything.
ok I figure it out. the problem was that I add
require 'common.php'before main IF statment. My whole code were like thisso when i moved require to other place everythig works great!
Thanks mates for help! 🙂