Benim kod temelde 127px tarafından 219px için görüntü kırpma ve veritabanına görüntü kaydetmek ama hatalar alıyorum ve onu anlamaya olamaz gerekir.
<?php
if(isset($_POST['btnupload']) && $_FILES['imglogo']['size'] > 0) {
$tmpname = $_FILES['imglogo']['tmp_name'];
$imgsize = $security->secure($_FILES['imglogo']['size']);
$imgtype = $security->secure($_FILES['imglogo']['type']);
$school = $security->secure($_POST['school']);
//crop image
$canvas = imagecreatetruecolor(219,127);
$imgattrib = getimagesize($tmpname);
$source = imagecreatefromjpeg($tmpname);
imagecopyresized($canvas,$source,0,0,0,0,219,127,$imgattrib[0],$imgattrib[1]);
$handle = fopen($tmpname, "r");
$content = fread($handle, filesize($tmpname));
$content = addslashes($content);
fclose($handle);
$save = mysql_query("insert into tbl_school_preview values(null,'$school','$content','$imgtype','$imgsize')") or die(mysql_error());
//header("Location: school-catalog.php?page=school_preview");
}
?>
Ben herhangi bir hata görmüyorum ama kırpma olmuyor. Ben yanlış bir şey var mı?
[Updated code] Here is the new piece of block for some reason the thumb won't save.
if(isset($_POST['btnupload']) && $_FILES['imglogo']['size'] > 0) {
//$filename = $security->secure($_FILES['imgschool']['name']);
$tmpname = $_FILES['imglogo']['tmp_name'];
$imgsize = $security->secure($_FILES['imglogo']['size']);
$imgtype = $security->secure($_FILES['imglogo']['type']);
$school = $security->secure($_POST['school']);
//crop image
$canvas = imagecreatetruecolor(219,127);
$imgattrib = getimagesize($tmpname);
$source = imagecreatefromjpeg($tmpname);
imagecopyresized($canvas,$source,0,0,0,0,219,127,$imgattrib[0],$imgattrib[1]);
$newfile = imagejpeg($canvas,'thumb.jpg',100);
$handle = fopen($newtmpfile, "r");
$content = fread($newtmpfile, filesize($newtmpfile));
$content = addslashes($content);
fclose($handle);
$save = mysql_query("insert into tbl_school_preview values(null,'$school','$content','$imgtype','$imgsize')") or die(mysql_error());