|
 |
|
ดูโค้ดให้หน่อยครับ Thumbnails ไม่ขึ้นครับ กับสงสัยตรง ImageCreateFromJPEG |
|
 |
|
|
 |
 |
|
ดูโค้ดให้หน่อยครับ Thumbnails อัพไม่ลงโฟลเดอร์ ครับ กับสงสัยตรง ImageCreateFromJPEG
ถ้าจะใช้หลายๆ อันละ่เช่น GIF PNG BMP JPG
Code (PHP)
//upload single file
if($_FILES['fileupload']['error']==0)
{
//Type Allow
if((($_FILES['fileupload']['type']=="image/pjpeg")
||($_FILES['fileupload']['type']=="image/jpg")
||($_FILES['fileupload']['type']=="image/gif")
||($_FILES['fileupload']['type']=="image/png"))
&&($_FILES['fileupload']['size']<200000)) //1kb=1mb
{
//upload & Resize
if(trim($_FILES["fileUpload"]["tmp_name"]) != "")
{
$rand=time();
$images = $_FILES["fileupload"]["tmp_name"];
$new_images = "Thumbnail_".$_FILES["fileupload"]["name"];
move_uploaded_file($_FILES["fileupload"]["tmp_name"],"../uploads/product/".$_FILES["fileupload"]["name"]); --> บรรทัดนี้ได้ครับ
$width=106; //*** Fix Width & Heigh (Autu caculate) ***//
$size=GetimageSize($images);
$height=round($width*$size[1]/$size[0]);
$images_orig = ImageCreateFromJPEG($images);-->เขียนแบบนี้ได้ป่าว
$images_orig = ImageCreateFromPNG($images);-->เขียนแบบนี้ได้ป่าว
$images_orig = ImageCreateFromGIF($images);-->เขียนแบบนี้ได้ป่าว
$photoX = ImagesX($images_orig);
$photoY = ImagesY($images_orig);
$images_fin = ImageCreateTrueColor($width, $height);
$img=$rand."_".$images;
ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY);
ImageJPEG($images_fin,"../uploads/product/".$new_images); --> บรรทัดนี้ ไม่ถูกอัพโหลดเลยครับ
ImageDestroy($images_orig);
ImageDestroy($images_fin);
}
}else{
msgbox("file type not allow");
redirect("imgshow.php");
}
}
//Add to DB
$sql="INSERT INTO tb_product";
$sql.="(CAT_ID,CODE,NAMEBOOK,CHECKSTOCK,PRICE,PRICE_MEMBER,STATUS,IMGBOOK,DATE_TODAY)";
$sql.="VALUES ('$addcat','$pro_code','$pro_name','$qstock','$price','$price_member','$pro_status','$img','$date_today')";
$rs=mysql_query($sql)or die (mysql_error());
//echo"sql : ".$sql;
if($rs){
redirect("product.php");
}else{
msgbox("Don't Success");
}
}//if
Tag : PHP

|
ประวัติการแก้ไข 2010-10-28 16:24:49
|
 |
 |
 |
 |
Date :
2010-10-28 16:22:58 |
By :
nottpoo |
View :
956 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
$images = $_FILES["fileupload"]["tmp_name"];
$new_images = "Thumbnail_".$_FILES["fileupload"]["name"];
move_uploaded_file($_FILES["fileupload"]["tmp_name"],"../uploads/product/".$_FILES["fileupload"]["name"]);
$width=106; //*** Fix Width & Heigh (Autu caculate) ***//
$size=GetimageSize($images);
$height=round($width*$size[1]/$size[0]);
$images_orig = ImageCreateFromJPEG($images);-->เขียนแบบนี้ได้ป่าว
$images_orig = ImageCreateFromPNG($images);-->เขียนแบบนี้ได้ป่าว
$images_orig = ImageCreateFromGIF($images);-->เขียนแบบนี้ได้ป่าว
ผมเข้าใจว่า $images คือ $_FILES["fileupload"]["tmp_name"];
ซึ่งมันถูกย้ายเมื่ออัปโหลดไปแล้วด้วย move_uploaded_file ดังนั้น $images ก็ไม่มีอยู่แล้ว ลองเช็คด้วย file_exists() ก็ได้
ตัวที่จะเอามาย่อภาพน่าจะเป็น "../uploads/product/".$_FILES["fileupload"]["name"] มากกว่า ซึ่งอาจต้องหา path ของมันจริงๆอีกที
แนะนำโค้ดย่อภาพครับ
http://www.okvee.net/2010/06/28/v-image-class/
|
 |
 |
 |
 |
Date :
2010-10-28 16:46:32 |
By :
mr.v |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|