|
 |
|
ไม่รู้ว่าทำไมถึงเออเร่ออ่ะครับ [Resize image] ไม่รู้ว่าทำไมถึงเออเร่ออ่ะครับมัน copy file ได้ |
|
 |
|
|
 |
 |
|
ไม่รู้ว่าทำไมถึงเออเร่ออ่ะครับ
มัน copy file ได้ แต่ว่ามันไม่ resize อ่ะครับ งง
Code (PHP)
<?
include("config.php");
$username=$_SESSION['username'];
$id=$_SESSION['user_id'];
mysql_query("SET character_set_results=UTF-8");
$picture=$_POST['picture'];
$picture =$_FILES['picture']['tmp_name'];
$picture_name =$_FILES['picture']['name'];
//$picture_size =$_FILES['picture']['size'];
$picture_type =$_FILES['picture']['type'];
if (!$picture) {
echo (' ไม่สามารถ Upload รูปภาพได้ <br>
');
}
else
{
$array_last=explode (".", $picture_name) ;
$c=count ($array_last)-1;
$lastname=strtolower ($array_last [$c]);
if ($lastname=="gif" or $lastname=="jpg" or $lastname=="jpeg") {
copy ($picture, "../picture/".$picture_name) ; //ทำการ copy รูป
$images = $_FILES['picture']['name'];
$height = 140; //กำหนดขนาดความสูง
$size = getimagesize($images);
$width = round($height*$size[0]/$size[1]); //ขนาดความกว้่างคำนวนเพื่อความสมส่วนของรูป
if($size[2] == 1) {
$images_orig = imagecreatefromgif($images); //resize รูปประเภท GIF
} else if($size[2] == 2) {
$images_orig = imagecreatefromjpeg($images); //resize รูปประเภท JPEG
}
$photoX = imagesx($images_orig);
$photoY = imagesy($images_orig);
$images_fin = imagecreatetruecolor($width, $height);
imagecopyresampled($images_fin, $images_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY);
imagejpeg($images_fin, $images); //ชื่อไฟล์ใหม่
imagedestroy($images_orig);
imagedestroy($images_fin);
echo (' เพิ่มรูปภาพเรียบร้อยแล้วครับ ');
$sql="update tb_faceblog set pic_blog='$picture_name' where user_id ='$id' ";
$datetime=date("Y-m-d H:i:s");
$strcommand1="insert into tb_picblog values ('','$picture_name','$datetime','$id')";
$result=mysql_db_query($db,$strcommand,$conn);
$result1=mysql_db_query($db,$strcommand1,$conn);
$result=mysql_db_query($db,$sql,$conn);
if($result){
}
else{
echo "no";
}
if($result1){
// echo"<meta http-equiv='refresh' content='2;url=../administrator/index.php?'>";
}
else{
echo "no";
}
}
else
{
echo (' เฉพาะรูปภาพนามสกุล *.gif, *.jpg, *.jpeg เท่านั้นครับ
<meta http-equiv="refresh" content="2;URL=upload_pic.php">
');
}
unlink($picture);
}
?>
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2010-06-15 13:39:46 |
By :
keapkung |
View :
954 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันเออเร่อบรรทัดที่ 29 -42 อ่ะครับ
|
 |
 |
 |
 |
Date :
2010-06-15 13:41:20 |
By :
keapkung |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองเปลี่ยนตรงบรรทัด 27 ตัวแปร $images เป็นแบบนี้ดูนะ
$images = "../picture/".$picture_name;
|
 |
 |
 |
 |
Date :
2010-06-15 14:15:48 |
By :
heng |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้วครับ ขอบคุณมากๆครับ ผมเพิ่งศึกษาอ่ะครับ อ่านโค้ดยังงงอยู่ว่ามันจะไปยังมายังงัยอ่ะครับ
ขอคุณมากๆครับ
|
 |
 |
 |
 |
Date :
2010-06-15 16:42:10 |
By :
keapkung |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|