ช่วยดูให้หน่อยครับทำไมเพิ่มรูปไม่ได้อะครับพี่

เกี่ยวกับ ฐานข้อมูล MySql Oracle MSSQL ect..

Moderator: phpbb, mindphp

ตอบกลับโพส
ounamo
phpBBThailand Newbie
phpBBThailand Newbie
โพสต์: 2
ลงทะเบียนเมื่อ: 17 พ.ค. 2010, 12:02

ช่วยดูให้หน่อยครับทำไมเพิ่มรูปไม่ได้อะครับพี่

โพสต์ โดย ounamo »

โค๊ดrephotoweb.php
<?
/* include "chksession.php"; */
$photo=$_FILES['photo']['tmp_name'];
$photo_name=$_FILES['photo']['name'];
$photo_size=$_FILES['photo']['size'];
$photo_type=$_FILES['photo']['type'];

$keyword =$_POST['keyword'];
$url =$_POST['url'];
$title =$_POST['title'];
$description =$_POST['description'];
$photo =$_POST['photo'];

$ext = strtolower(end(explode('.',$photo_name)));
echo"$ext";
if($ext =="jpg"|| $ext == "jpeg" || $ext == "png" || $ext =="gif"){

include "connect.php" ;

$sql ="update tb_url set keyword ='$keyword', url ='$url',title ='$title',description='$description' where username ='ounamo' ";
$result = mysql_db_query ($dbname,$sql);
echo"$sql<br>";

$sql = "select * from tb_url where username ='ounamo' ";
$result = mysql_db_query ($dbname,$sql);

$photos = mysql_fetch_array($result);
$namephoto=$photos['username'];

$filename =$namephoto.".".$ext;
copy ($photo,"images_large/$filename");
if ($ext =="jpg" or $ext == "jpeg")
{
$ori_img = imagecreatefromjpeg($photo);
}
else if ($ext =="png")
{
$ori_img = imagecreatefrompng($photo);
}
else if ($ext =="gif")
{
$ori_img = imagecreatefromgif($photo);
}
$ori_size = getimagesize( $photo);
$ori_w = $ori_size[0];
$ori_h = $ori_size[1];

if ( $ori_w >= $ori_h)
{
$new_w = 140 ;
$new_h = 105 ;
}
else
{
$new_h = 105 ;
$new_w = 140 ;
}
$new_img = imagecreatetruecolor($new_w,$new_h);
imagecopyresized($new_img,$ori_img,0,0,0,0,$new_w,$new_h,$ori_w,$ori_h);

if ($ext =="jpg" or $ext == "jpeg")
{
imagejpeg($new_img,"images_small/$filename");
}
else if ($ext =="png")
{
imagepng($new_img,"images_small/$filename");
}
else if ($ext =="gif")
{
imagegif($new_img,"images_small/$filename");
}
imagedestroy($ori_img);
imagedestroy($new_img);

$sql ="update tb_url set photo='$filename' where username ='ounamo' ";
$result = mysql_db_query ($dbname,$sql);
echo"$result";
if ($result)
{
?>

<html>
<meta http-equiv="refresh" content="0; URL=profile.php?checkprofile= 2">

<?
}

}

?>


error
Warning: imagecopyresized(): supplied argument is not a valid Image resource in C:\AppServ\www\Test\reprotoweb.php on line 60

Warning: imagedestroy(): supplied argument is not a valid Image resource in C:\AppServ\www\Test\reprotoweb.php on line 74
happyber
phpBBThailand Newbie
phpBBThailand Newbie
โพสต์: 1
ลงทะเบียนเมื่อ: 22 ม.ค. 2009, 11:40
ติดต่อ:

Re: ช่วยดูให้หน่อยครับทำไมเพิ่มรูปไม่ได้อะครับพี่

โพสต์ โดย happyber »

ลองหาดู เกี่ยวกับการ resize รูป
ตอบกลับโพส

ย้อนกลับไปยัง

ผู้ใช้งานขณะนี้

กำลังดูบอร์ดนี้: 83 และ บุคคลทั่วไป 0 ท่าน