พบกับบทความเกี่ยวกับคอมพิวเตอร์และ programming ได้ที่ http://articles.modoeye.com | บล็อกอาหาร
PHP development / ช่วยดูให้หน่อยคับ
it-it
it-it
Tue 1 Apr 2008 20:54:23

<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<form name="form1" enctype="multipart/form-data" method="post" action="">
  <table width="900" border="0" align="center" cellpadding="2" cellspacing="0">
    <tr>
      <td width="216" valign="top"><div align="right">รูป  : </div></td>
      <td width="684"><input name="file" type="file" ></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input name="addnews" type="submit" id="addnews" value="ส่งข้อมูลเข้าสู่ดาต้าเบส" /></td>
    </tr>
  </table>
</form>
<?php
if(isset($_POST["addnews"]))
{
  $images = $_FILES["file"]["tmp_name"];
  $width = 210;
  $size=GetimageSize($images);
  $height=round($width*$size[1]/$size[0]);
  $images_orig = ImageCreateFromJPEG($images);
  $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,$file_name);
  ImageJPEG($images_fin,$file);
  ImageDestroy($images_orig);
  ImageDestroy($images_fin);
  $picture = $file_name;
  echo '<img src="',$picture,'">';
}
?>

คือว่าโค๊ชนี้ มันอัพรูปแล้ว มันใช้ชื่อรูปเลย ถ้าอัพรูปที่มีชื่อรูปซ้ำมันก็ไม่อัพให้ พอจะมีวิธีให้อัพรูปชื่อซ้ำได้ไหมคับ

webmaster
webmaster
Tue 1 Apr 2008 22:26:40
ก็ทำการตรวจสอบก่อนครับว่ามีไฟล์ชื่อนั้นหรือไม่ด้วย is_file() ถ้ามีก็ใส่อะไรต่อท้ายลงไปให้ไม่ซ้ำกัน ถ้ากลัวว่าจะซ้ำอีกก็เอาทั้งหมดนั้นไปใส่ loop while เอาครับ
it-it
it-it
Wed 2 Apr 2008 11:00:55

พี่ ขอเต็มๆได้ไหมอ่าคับ บังเอิญไม่ค่อยเก่งเรื่อง โค๊ดด้วยสิ  ขออีกข้อ 1 นะ คือว่าจะให้อัพแต่สกุล JPG ต้องเขียนโค๊ดเพิ่มไงหรอ

webmaster
webmaster
Wed 2 Apr 2008 12:52:09
การจะหานามสกุลของไฟล์ก็ตัดเอา string ที่อยู่หลัง . ดูว่ามีค่าตามต้องการหรือไม่
it-it
it-it
Wed 2 Apr 2008 18:06:08

แง่ไม่เก่งเรื่องโค๊ด ทำมะถูกอ่า อยากให้ พี่เว็บมาสเตอร์เขียวให้ได้ไหม รบกวนหน่อยนะคับ

webmaster
webmaster
Wed 2 Apr 2008 20:00:39
ใน document ของ php.net มีทุกอย่างครับ โค๊ดที่ว่าก็มีครับแต่แยกกันอยู่ ลองอ่านให้มากขึ้นครับ ผมไม่ coding ให้ครับสามารถให้ได้เพียงแนวทางและ correction เท่านั้น พยายามดูก่อนครับ
it-it
it-it
Wed 2 Apr 2008 20:09:37

อืมๆ ขอบคุงคับ งมต่อ

Reply
Name:
E-mail:
Home | Services | Forum | Classified | Directories | Support | Contact
ATOM feed RSS 0.9 feed RSS 1.0 feed RSS 2.0 feed
Copyright © 2005 - 2007 Modoeye.com, All Rights Reserved.
Disclaimer | Privacy policy | Term of Use | Term of Services
Valid XHTML Valid CSS! PHP: Hypertext Preprocessor MySQL database Apache Powered! FreeBSD Power to serve
Modoeye Sitemap Client login