|
 |
|
โค้ดรีไซด์รูปภาพ ครับ Output imagejpeg($thumb); มันไม่ทำงาน เกิดขึ้นเพราะอะไรใครทราบช่วยที่ครับ |
|
 |
|
|
 |
 |
|
<?php
// File and new size
$filename = "fate.jpg";
$percent = 0.5;
// Content type
header('Content-type: image/jpeg');
// Get new sizes
list($width, $height) = getimagesize($filename);
echo $newwidth = $width * $percent;
echo $newheight = $height * $percent;
// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);
// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
// Output
imagejpeg($thumb);
?>
มันไม่ทำงาน เกิดขึ้นเพราะอะไรใครทราบช่วยที่ครับ
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
1 ธ.ค. 2549 10:12:16 |
By :
มดตัวน่อย |
View :
2549 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองอันนี้ดูนะครับ ผมประยุกต์จากโคดภายในเว็บนี้และ อ่านและเรียนจากเว็บนี้ทั้งหมดเลย
1. สร้าง Folder ใน www ในที่นี้สร้างชื่อว่า mygallery
2. สร้าง Folder ชื่อ photo และ thumb ไว้ใน mygallery
3. เอาโค้ดข้างล่างนี้เก็บไว้ใน mygallery
upfile.php
<META http-equiv=Content-Type content="text/html; charset=windows-874">
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="photo">
<br>
<input type ="submit" value="Send">
</form>
<?
$photo_tmp=$_FILES[photo][tmp_name];
$photo_name=$_FILES[photo][name];
$photo_type=$_FILES[photo][type];
$photo_size=$_FILES[photo][size];
if($photo_tmp==""){
echo "เลือกไฟล์ที่จะ upload....<hr>";
}else{
echo "Path Files : $photo_tmp<br>";
echo "Name : $photo_name<br>";
echo "Type : $photo_type<br>";
echo "Size : $photo_size";
echo "<hr>";
move_uploaded_file($photo_tmp,"./photo/".$photo_name);
#เริ่มสร้างภาพขนาดเล็กหรือใหญ่ตามต้องการ
$ThumbPhoto="./photo/";
$ThumbFile=$ThumbPhoto.$photo_name;
$ThumbH=120;
$Quality=100;
List($SourceW,$SourceH)=GetImageSize($ThumbFile);
$Percent=$ThumbH/$SourceH ;
$ThumbW=$SourceW*$Percent;
$ImgTarget=ImageCreateTrueColor($ThumbW,$ThumbH);
$ImgSource=ImageCreateFromJpeg($ThumbFile);
#ImageCopyResampled($ImgTarget,$ImgSource,0,0,0,0,$ThumbW,$ThumbH,$SourceW,$SourceH);
ImageCopyResampled($ImgTarget,$ImgSource,0,0,0,0,$ThumbW,$ThumbH,$SourceW,$SourceH);
ImageJpeg($ImgTarget,"./thumb/".$photo_name,$Quality);
ImageDestroy($ImgTarget);
ImageDestroy($ImgSource);
echo "อัปโหลดเสร็จแล้ว...<hr>";
}
?>
<?
$folder='./thumb/';
$dir=opendir($folder);
$i=1;
echo"<table border=1 cellspacing=0 cellpadding=5 bordercolordark=white>"
."<tr align=center>";
while($files=readdir($dir)){
$exp=explode(".",$files);
$c=count($exp)-1;
$type=strtolower($exp[$c]);
if ($type=="jpg" or $type=="gif"){
echo "<td>";
?>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TR>
<TD align="middle">
<?
echo "<a href='./photo/$files'><img src='./thumb/$files' border=0></a>";
?>
</TD>
<TD vAlign="top" background="images/shadow_12.gif" style="background-image: url('images/shadow_12.gif'); background-repeat: repeat-y; background-position-x: left" >
<IMG src="images/shadow_08.gif">
</TD>
</TR>
<TR>
<TD background="images/shadow_15.gif"><IMG src="images/shadow_14.gif" ></TD>
<TD width="7" ><IMG src="images/shadow_16.gif" ></TD></TR></TABLE>
<?
echo "</td>";
$x=$i%3;
if ($x==0){ echo"</tr><tr align=center>"; }
$i=$i+1;
}
}
echo "</td></tr></table>";
closedir($dir);
?>
===========================
ผมลองแล้วใช้ได้ผลนะ
ด้วยความนับถือ
[email protected]
=====================================
|
 |
 |
 |
 |
Date :
4 ธ.ค. 2549 17:21:52 |
By :
mrsitti |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
[email protected]
จะลองดูครับ ขอบคุฯ น่ะครับ
|
 |
 |
 |
 |
Date :
6 ธ.ค. 2549 13:56:29 |
By :
มดตัวน่อย |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|