Page 1 of 1

Resize image

Posted: 15/01/2009 10:37 pm
by qwerty2528
ขอความกรุณาท่านผู้รู้ ช่วยเขียนโคดการ resize image ตอนอัพโหลดรูปหนอ่ยครับ

<?
session_start ();
if ($sess_adminid<>session_id() ) {
header("location: admin.php"); exit();
}
$id_edit=$_POST[id_edit]; //
$name=$_POST[name];
$ref_id_type=$_POST[ref_id_type];
$detail=$_POST[detail];
$price=$_POST[price];

$photo=$_POST[photo]; //
$fileupload=$_FILES['fileupload']['tmp_name']; //
$fileupload_name=$_FILES['fileupload']['name'];
$fileupload_size=$_FILES['fileupload']['size'];
$fileupload_type=$_FILES['fileupload']['type'];

include "connect.php";
$sql="INSERT INTO tb_product
VALUES(null, '$name', '$ref_id_type', '$detail', '$price', ' ') ";
$result=mysql_db_query($dbname,$sql) ;
if ($fileupload) {
$array_last=explode(".", $fileupload_name);
$c=count($array_last) -1;
$lastname=strtolower($array_last[$c]) ;

if ($lastname=="gif" or $lastname=="jpg" or $lastname="jpeg" or $lastname="png") {
// or $lastname="png"

$sql2="select max(id_prd) from tb_product " ;
$result2=mysql_db_query($dbname,$sql2);
$row=mysql_fetch_row($result2);

$photoname=$row[0].".".$lastname;

copy ($fileupload,"photo/".$photoname);

$sql3="update tb_product set photo_prd='$photoname'
where id_prd ='$row[0]' ";
$result3=mysql_db_query($dbname,$sql3);
}

unlink ($fileupload);
}
echo " OK , clear" ;
echo "[ <a href=admin_product.php> Home </a>] ";
mysql_close();
?>

*** ขอบพระคุณอย่างสูงครับ

Re: Resize image

Posted: 17/01/2009 6:41 pm
by mindphp
ต้องศึกษา function พวก
ลองดู function นี้ครับ
https://www.mindphp.com/modules.php?name ... mpled.html