Why might this work on my server but not my schools?
Posted
by Doug
on Stack Overflow
See other posts from Stack Overflow
or by Doug
Published on 2010-05-19T08:53:20Z
Indexed on
2010/05/19
9:00 UTC
Read the original article
Hit count: 207
I created a captcha just now, and it works PERFECTLY on my own server. On the school's server, it doesn't generate an image. Why might this be? The difference in code is one line.
*Edit:*Originally, it was working, but I deleted the directory by mistake and I do not know why did it suddenly work in the first place.
Source code on school server:
<?php
session_save_path("/ichanged/this/path/for/this/post/");
session_start();
$img=imagecreatefromjpeg("bg.jpg");
if( empty($_SESSION['captcha_numbers']) ) {
$captcha_numbers = 'error';
} else {
$captcha_numbers = $_SESSION['captcha_numbers'];
}
$image_numbers=$captcha_numbers;
$red=rand(100,150);
$green=rand(100,255);
$blue=rand(100,255);
$color=imagecolorallocate($img,255-$red,255-$green,255-$blue);
$text=imagettftext($img,12,rand(-7,7),rand(10,20),rand(20,30),$color,"fonts/M04.TTF",$image_numbers);
header("Content-type:image/jpeg");
header("Content-Disposition:inline ; filename=secure.jpg");
imagejpeg($img);
?>
Source code on my server:
<?php
session_start();
$img=imagecreatefromjpeg("bg.jpg");
if( empty($_SESSION['captcha_numbers']) ) {
$captcha_numbers = 'error';
} else {
$captcha_numbers = $_SESSION['captcha_numbers'];
}
$image_numbers=$captcha_numbers;
$red=rand(100,150);
$green=rand(100,255);
$blue=rand(100,255);
$color=imagecolorallocate($img,255-$red,255-$green,255-$blue);
$text=imagettftext($img,12,rand(-7,7),rand(10,20),rand(20,30),$color,"fonts/M04.TTF",$image_numbers);
header("Content-type:image/jpeg");
header("Content-Disposition:inline ; filename=secure.jpg");
imagejpeg($img);
?>
© Stack Overflow or respective owner