|
 |
|
code resize image ** ขอความกรุณาช่วยเช็คโคดในคอมเม้นให้หน่อยครับ มันไม่ทำงาน** |
|
 |
|
|
 |
 |
|
** ขอความกรุณาช่วยเช็คโคดในคอมเม้นให้หน่อยครับ มันไม่ทำงาน** ขอบคุณอย่างสูง
Code (PHP)
<?
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") {
$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);
/*
if ($lastname == "jpg" or $lastname == "jpeg") {
$ori_img = imagecreatefromjpeg($fileupload);
} else if ($lastname == "png") {
$ori_img = imagecreatefrompng($fileupload);
} else if ($lastname == "gif") {
$ori_img = imagecreatefromgif($fileupload);
}
$ori_size = getimagesize($fileupload);
$img_w = $ori_size[0];
$img_h = $ori_size[1];
if ($img_w > 150) {
$new_w = 150;
$new_h = round(($new_w/$img_w) * $img_h);
$new_img = imagecreatetruecolor($new_w, $new_h);
imagecopyresized( $new_img, $ori_img, 0, 0, 0, 0, $new_w, $new_h, $img_w, $img_h);
if ($lastname == "jpg" or $lastname == "jpeg") {
imagejpeg($new_img, $fileupload_name);
} else if ($lastname == "png") {
imagepng($new_img, $fileupload_name);
} else if ($lastname == "gif") {
imagegif($new_img, $fileupload_name);
}
imagedestroy($ori_img);
imagedestroy($new_img);
}
*/
$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();
?>
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2009-01-16 14:15:36 |
By :
PHP nerd |
View :
1314 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่ทำงาน คือ ว่ามันไม่มี ไฟล์ที่ ปรับขนาดแล้วใช่มั้ยคับ
เปิด GD ยังคับ ไม่ใช้ imagecopyresampled() เหรอคับ
ปรับโหมดของ ไดเรคทอรี่เป็น 777 ยังคับ
เก็บไฟล์ไว้ที่เดียวกันกับสคริปเหรอคับ
หรือว่า ชื่อไฟล์ไม่เข้าฐานข้อมูลดูจากคิวรี่แล้ว id_prd น่า จะเป็น integer นะครับ
ไม่น่าจะมี sigle qoute ตรง $sql3
SITE: http://gunner.freetzi.com/newVer
MSN: [email protected]
TEL: 087-577-0276
|
 |
 |
 |
 |
Date :
2009-01-16 15:24:36 |
By :
pjgunner |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|