Hi, I have installed GD Lib 1.8.4 on my server. I have used the following code:
$sizelim = "yes";
$size = "150000";
$certtype = "yes";
$type = "image/pjpeg";
if ($file_name == "") {
die("No file selected to upload");
}
//error if file exists
if (file_exists("$updir/$file_name")) {
die("The file you are trying to upload already exists under that name.");
}
//error if file is to big
if ($sizelim == "yes") {
if ($file_size > $size) {
die("The file you are trying to upload is too big.");
}
}
//error if file isn't certain type
if ($certtype == "yes") {
if ($type != $file_type) {
die("The file you are trying to upload is wrong type. Please use jpg images only.");
}
}
@copy($file, "$updir/$file_name") or die("The file you are trying to upload couldn't be copied to the server");
$src_img = imagecreatefromjpeg($file);
$new_w = imagesx($src_img)/4;
$new_h = imagesy($src_img)/4;
$dst_img = imagecreate($new_w,$new_h);
imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),imagesy($src_img));
imagejpeg($dst_img, "images/$imagefile");
echo "<img src=scratch/$imagefile>\n";
The main image is copied onto the server, but the smaller image that should be created does not work. I get the following error:
Fatal error: Call to undefined function: imagecreatefromjpeg()
Any help anyone?
Thanks in advance.
-jfv