Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > ผมสร้างไฟล์อัพโหลดรูปภาพ พร้อมฟอร์มรายละเอียดข้อความหลายภาพ แต่อยากให้ อัพโหลดได้ทั้งหมด ในปุ่ม Submit ปุ่มเดียว ต้องทำอย่างไรครับ



 

ผมสร้างไฟล์อัพโหลดรูปภาพ พร้อมฟอร์มรายละเอียดข้อความหลายภาพ แต่อยากให้ อัพโหลดได้ทั้งหมด ในปุ่ม Submit ปุ่มเดียว ต้องทำอย่างไรครับ

 



Topic : 120368



โพสกระทู้ ( 23 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook



ฟอร์ม ที่อัพโหลด
Code (PHP)
<form action="gallery_add.php" method="post" enctype="multipart/form-data" name="form1" id="form3">
                <table width="700" border="0" align="center" cellpadding="0" cellspacing="0" background="images/bgload.jpg">
                  <tr>
                    <td width="76" height="45">&nbsp;</td>
                    <td width="7" rowspan="2">&nbsp;</td>
                    <td width="218">&nbsp;</td>
                    <td width="55">&nbsp;</td>
                    <td width="50">&nbsp;</td>
                    <td width="88">&nbsp;</td>
                    <td width="67">&nbsp;</td>
                    <td width="50">&nbsp;</td>
                    <td width="89">&nbsp;</td>
                  </tr>
                  <tr>
                    <td width="76" height="24" align="right">รูปภาพที่ 1: </td>
                    <td><input name="file[]" type="file" id="file[]" /></td>
                    <td align="right">ชื่อภาพ: </td>
                    <td align="center"><input name="txtname[]" type="text" id="txtname[]" size="5" /></td>
                    <td align="right"><label for="date">รายละเอียด:</label></td>
                    <td align="center"><input name="txtdetail[]" type="text" id="txtdetail[]" size="5" /></td>
                    <td align="right">วันที:่</td>
                    <td align="center"><input name="datepicker[]" type="text" id="datepicker[]" value="" size="5" /></td>
                  </tr>
                  <tr>
                    <td height="28" align="right">รูปภาพที่ 2 : </td>
                    <td>&nbsp;</td>
                    <td><input name="file[]" type="file" id="file[]" /></td>
                    <td align="right">ชื่อภาพ:</td>
                    <td align="center"><input name="txtname[]" type="text" id="txtname[]" size="5" /></td>
                    <td align="right">รายละเอียด:</td>
                    <td align="center"><input name="txtdetail[]" type="text" id="txtdetail[]" size="5" /></td>
                    <td align="right">วันที่:</td>
                    <td align="center"><input name="datepicker[]" type="text" id="datepicker[]" value="" size="5" /></td>
                  </tr>
                  <tr>
                    <td height="29" align="right">&nbsp;รูปภาพที่ 3 : </td>
                    <td>&nbsp;</td>
                    <td><input name="file[]" type="file" id="file[]" /></td>
                    <td align="right">ชื่อภาพ:</td>
                    <td align="center"><input name="txtname[]" type="text" id="txtname[]" size="5" /></td>
                    <td align="right">รายละเอียด:</td>
                    <td align="center"><input name="txtdetail[]" type="text" id="txtdetail[]" size="5" /></td>
                    <td align="right">วันที่:</td>
                    <td align="center"><input name="datepicker[]" type="text" id="datepicker[]" value="" size="5" /></td>
                  </tr>
                  <tr>
                    <td height="29" align="right">รูปภาพที่ 4 : </td>
                    <td>&nbsp;</td>
                    <td><input name="file[]" type="file" id="file[]" /></td>
                    <td align="right">ชื่อภาพ:</td>
                    <td align="center"><input name="txtname[]" type="text" id="txtname[]" size="5" /></td>
                    <td align="right">รายละเอียด:</td>
                    <td align="center"><input name="txtdetail[]" type="text" id="txtdetail[]" size="5" /></td>
                    <td align="right">วันที่:</td>
                    <td align="center"><input name="datepicker[]" type="text" id="datepicker[]" value="" size="5" /></td>
                  </tr>
                  <tr>
                    <td height="29" align="right">รูปภาพที่ 5 : </td>
                    <td>&nbsp;</td>
                    <td><input name="file[]" type="file" id="file[]" /></td>
                    <td align="right">ชื่อภาพ:</td>
                    <td align="center"><input name="txtname[]" type="text" id="txtname[]" size="5" /></td>
                    <td align="right">รายละเอียด:</td>
                    <td align="center"><input name="txtdetail[]" type="text" id="txtdetail[]" size="5" /></td>
                    <td align="right">วันที่:</td>
                    <td align="center"><input name="datepicker[]" type="text" id="datepicker[]" value="" size="5" /></td>
                  </tr>
                  <tr>
                    <td height="30" align="right">รูปภาพที่ 6 : </td>
                    <td>&nbsp;</td>
                    <td><input name="file[]" type="file" id="file[]" /></td>
                    <td align="right">ชื่อภาพ:</td>
                    <td align="center"><input name="txtname[]" type="text" id="txtname[]" size="5" /></td>
                    <td align="right">รายละเอียด:</td>
                    <td align="center"><input name="txtdetail[]" type="text" id="txtdetail[]" size="5" /></td>
                    <td align="right">วันที่:</td>
                    <td align="center"><input name="datepicker[]" type="text" id="datepicker[]" value="" size="5" /></td>
                  </tr>
                  <tr>
                    <td height="31" align="right">รูปภาพที่ 7 : </td>
                    <td>&nbsp;</td>
                    <td><input name="file[]" type="file" id="file[]" /></td>
                    <td align="right">ชื่อภาพ:</td>
                    <td align="center"><input name="txtname[]" type="text" id="txtname[]" size="5" /></td>
                    <td align="right">รายละเอียด:</td>
                    <td align="center"><input name="txtdetail[]" type="text" id="txtdetail[]" size="5" /></td>
                    <td align="right">วันที่:</td>
                    <td align="center"><input name="datepicker[]" type="text" id="datepicker[]" value="" size="5" /></td>
                  </tr>
                  <tr>
                    <td height="28" align="right">รูปภาพที่ 8 : </td>
                    <td>&nbsp;</td>
                    <td><input name="file[]" type="file" id="file[]" /></td>
                    <td align="right">ชื่อภาพ:</td>
                    <td align="center"><input name="txtname[]" type="text" id="txtname[]" size="5" /></td>
                    <td align="right">รายละเอียด:</td>
                    <td align="center"><input name="txtdetail[]" type="text" id="txtdetail[]" size="5" /></td>
                    <td align="right">วันที่:</td>
                    <td align="center"><input name="datepicker[]" type="text" id="datepicker[]" value="" size="5" /></td>
                  </tr>
                  <tr>
                    <td height="29" align="right">รูปภาพที่ 9 : </td>
                    <td>&nbsp;</td>
                    <td><input name="file[]" type="file" id="file[]" /></td>
                    <td align="right">ชื่อภาพ:</td>
                    <td align="center"><input name="txtname[]" type="text" id="txtname[]" size="5" /></td>
                    <td align="right">รายละเอียด:</td>
                    <td align="center"><input name="txtdetail[]" type="text" id="txtdetail[]" size="5" /></td>
                    <td align="right">วันที่:</td>
                    <td align="center"><input name="datepicker[]" type="text" id="datepicker[]" value="" size="5" /></td>
                  </tr>
                  <tr>
                    <td height="29" align="right">รูปภาพที่ 10 : </td>
                    <td>&nbsp;</td>
                    <td><input name="file[]" type="file" id="file[]" /></td>
                    <td align="right">ชื่อภาพ:</td>
                    <td align="center"><input name="txtname[]" type="text" id="txtname[]" size="5" /></td>
                    <td align="right">รายละเอียด:</td>
                    <td align="center"><input name="txtdetail[]" type="text" id="txtdetail[]" size="5" /></td>
                    <td align="right">วันที่:</td>
                    <td align="center"><input name="datepicker[]" type="text" id="datepicker[]" value="" size="5" /></td>
                  </tr>
                  <tr>
                    <td height="39" colspan="9" align="center"><input type='hidden' name='ID_album' value='<?=$ID_album?>' />
                      <input type="submit" name="Submit" value="อัฟโหลดรูปภาพ" />
                      &nbsp; &nbsp;&nbsp; &nbsp;
                      <input type="button" name="button2" id="button3" value="ยกเลิก"  onclick="window.history.back();"/></td>
                  </tr>
                </table>
                <p>&nbsp;</p>
              </form>


ไฟล์ save
Code (PHP)
<?php 
 include("class_dethai.php");
include ("class.imagesize.php"); 
include("conn.php");
$ID_album=$_POST[ID_album]; 
$name =$_POST[txtname];
$detail=$_POST[txtdetail];
$date1=$_POST[datepicker];

if(isset($_POST['Submit'] )) 
{ 
    $num_file = count($_FILES['file']['name']); 
    $select = false; 
    $count = 0; 
    for($i = 0; $i < $num_file ; $i++) //เนื่องจาก upload แบบ array เราจึงใช้ loop จัดการทีละไฟล์ 
    { 
        if($_FILES['file']['error'][$i] != 0) //ถ้าเกิดข้อผิดพลาดให้ข้ามไฟล์นนี้ไป 
        { 
            $count++; 
            continue; 
        } 
        if($_FILES['file']['name'][$i] != "") 
        { 
            $Filename = $_FILES['file']['name'][$i]; 
            $type = $_FILES['file']['type'][$i]; 
              //เก็บชื่อไฟล์เป็นเวลาขณะที่ upload แล้วตามด้วยนามสกุลไฟล์ ถ้าไฟล์มีชื่อเหมือนกันจะได้ไม่มีปัญหา 
          //สามารถ upload ไฟล์นามสกุล .gif, .png, .jpg, .zip, .docx, .pdf, .doc, .swf, .rar ได้ 
            $time = time() * microtime(); 
            if ( $type == "image/gif" ) {$Filename = $time.".gif"; $pic_type = 'GIF'; } 
            else if ( $type == "image/png" ) {$Filename = $time.".png"; $pic_type = 'PNG'; } 
            else if (( $type == "image/jpg") or ($type=="image/jpeg") or ($type == "image/pjpeg")){$Filename= $time.".jpg"; $pic_type = 'JPG'; } 
            else if ($type == "application/octet-stream" ) {$Filename = $time.".zip"; $pic_type = false;} 
            else if ($type == "application/vnd.openxmlformats-icedocument.wordprocessingml.document" ) {$Filename = $time.".docx"; $pic_type = false;} 
            else if ($type == "application/pdf" ) {$Filename = $time.".pdf"; $pic_type = false;} 
            else if ($type == "application/msword" ) {$Filename = $time.".doc"; $pic_type = false;} 
            else if ($type == "application/x-shockwave-flash" ) {$Filename = $time.".swf"; $pic_type = e;} 
            else if ($type == "application/octet-stream" ) {$Filename = $time.".rar"; $pic_type = false;} 
            //move ไฟล์ไปยังโฟลเดอร์ที่สร้างไว้ในที่นี้คือ fileupload 
            if(move_uploaded_file($_FILES['file']['tmp_name'][$i], 'gallery/'.$Filename)){ 
            //โค้ดในส่วนของการลดขนาดไฟล์รูปภาพ 
                if($pic_type){ 
                    $original_image = "gallery/" . $Filename ;  
                    $size = getimagesize($original_image); //ดึงขนาดของไฟล์ภาพมา 
                    $desired_height = 500 ; 
                    $desired_width = round($desired_height*$size[0]/$size[1]);
                    $image = new hft_image($original_image); 
                    $image->resize($desired_width, $desired_height, '0'); 
                    $image->output_resized("gallery/".$Filename, "JPG"); 
                } 
                //จัดเก็บชื่อไฟล์ลงฐานข้อมูล 
$sql = "INSERT INTO picture (ID_album,GalleryShot) VALUES ('$ID_album','{$Filename}');";
$rc = mysql_query($sql);
 if($rc){  
echo "บันทุึกข้อมูลเรียบร้อยแล้วครับ"; 
	 echo '<meta http-equiv="refresh" content="2;url=view_album.php">';
} else { 
echo "ไม่สามารถบันทึกข้อมูลได้ครับ";
 } 
            } 
        }else{ 
            $count++; 
        } 
    } 
}else{ 

    echo "คุณยังไม่ได้เลือกไฟล์ Upload"; 
} 

?>




Tag : PHP, MySQL, HTML/CSS, CakePHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2015-12-07 14:16:32 By : godzaa View : 1248 Reply : 5
 

 

No. 1



โพสกระทู้ ( 2,311 )
บทความ ( 1 )



สถานะออฟไลน์


เอาเงื่อนไข if() ข้างล่างนี้ไปไว้นอก for() loop ครับ เพราะ echo '<meta http-equiv="refresh" content="2;url=view_album.php">'; มันจะ redirect ไปหน้าอื่นเลยเมื่อบันทึกข้อมูลแรกสำเร็จ
Code
if($rc){ echo "บันทุึกข้อมูลเรียบร้อยแล้วครับ"; echo '<meta http-equiv="refresh" content="2;url=view_album.php">'; } else { echo "ไม่สามารถบันทึกข้อมูลได้ครับ"; }



Code (PHP)
<?php 
 include("class_dethai.php");
include ("class.imagesize.php"); 
include("conn.php");
$ID_album=$_POST[ID_album]; 
$name =$_POST[txtname];
$detail=$_POST[txtdetail];
$date1=$_POST[datepicker];

if(isset($_POST['Submit'] )) 
{ 
    $num_file = count($_FILES['file']['name']); 
    $select = false; 
    $count = 0; 
    for($i = 0; $i < $num_file ; $i++) //เนื่องจาก upload แบบ array เราจึงใช้ loop จัดการทีละไฟล์ 
    { 
        if($_FILES['file']['error'][$i] != 0) //ถ้าเกิดข้อผิดพลาดให้ข้ามไฟล์นนี้ไป 
        { 
            $count++; 
            continue; 
        } 
        if($_FILES['file']['name'][$i] != "") 
        { 
            $Filename = $_FILES['file']['name'][$i]; 
            $type = $_FILES['file']['type'][$i]; 
              //เก็บชื่อไฟล์เป็นเวลาขณะที่ upload แล้วตามด้วยนามสกุลไฟล์ ถ้าไฟล์มีชื่อเหมือนกันจะได้ไม่มีปัญหา 
          //สามารถ upload ไฟล์นามสกุล .gif, .png, .jpg, .zip, .docx, .pdf, .doc, .swf, .rar ได้ 
            $time = time() * microtime(); 
            if ( $type == "image/gif" ) {$Filename = $time.".gif"; $pic_type = 'GIF'; } 
            else if ( $type == "image/png" ) {$Filename = $time.".png"; $pic_type = 'PNG'; } 
            else if (( $type == "image/jpg") or ($type=="image/jpeg") or ($type == "image/pjpeg")){$Filename= $time.".jpg"; $pic_type = 'JPG'; } 
            else if ($type == "application/octet-stream" ) {$Filename = $time.".zip"; $pic_type = false;} 
            else if ($type == "application/vnd.openxmlformats-icedocument.wordprocessingml.document" ) {$Filename = $time.".docx"; $pic_type = false;} 
            else if ($type == "application/pdf" ) {$Filename = $time.".pdf"; $pic_type = false;} 
            else if ($type == "application/msword" ) {$Filename = $time.".doc"; $pic_type = false;} 
            else if ($type == "application/x-shockwave-flash" ) {$Filename = $time.".swf"; $pic_type = e;} 
            else if ($type == "application/octet-stream" ) {$Filename = $time.".rar"; $pic_type = false;} 
            //move ไฟล์ไปยังโฟลเดอร์ที่สร้างไว้ในที่นี้คือ fileupload 
            if(move_uploaded_file($_FILES['file']['tmp_name'][$i], 'gallery/'.$Filename)){ 
            //โค้ดในส่วนของการลดขนาดไฟล์รูปภาพ 
                if($pic_type){ 
                    $original_image = "gallery/" . $Filename ;  
                    $size = getimagesize($original_image); //ดึงขนาดของไฟล์ภาพมา 
                    $desired_height = 500 ; 
                    $desired_width = round($desired_height*$size[0]/$size[1]);
                    $image = new hft_image($original_image); 
                    $image->resize($desired_width, $desired_height, '0'); 
                    $image->output_resized("gallery/".$Filename, "JPG"); 
                } 
                //จัดเก็บชื่อไฟล์ลงฐานข้อมูล 
$sql = "INSERT INTO picture (ID_album,GalleryShot) VALUES ('$ID_album','{$Filename}');";
$rc = mysql_query($sql);
            } 

        }else{ 
            $count++; 
        } 
    } 
echo "บันทุึกข้อมูลเรียบร้อยแล้วครับ"; 
echo '<meta http-equiv="refresh" content="2;url=view_album.php">';
}else{ 

    echo "คุณยังไม่ได้เลือกไฟล์ Upload"; 
} 

?>









ประวัติการแก้ไข
2015-12-07 17:37:38
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-12-07 17:36:41 By : arm8957
 


 

No. 2



โพสกระทู้ ( 23 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

ตอบความคิดเห็นที่ : 1 เขียนโดย : arm8957 เมื่อวันที่ 2015-12-07 17:36:41
รายละเอียดของการตอบ ::
....ขอบคุณครับเดี๋ยวผมทดสอบดูครับ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-12-08 12:59:33 By : godzaa
 

 

No. 3



โพสกระทู้ ( 23 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

ทดสอบแล้วครับ ภาพเมื่อทำการ save แล้ว ภาพแสดงทั้งหมดครับ แต่ข้อความและรายละเอียดไม่มาด้วยครับ ไม่รู้ติดตรงไหน ข้อความขึ้นว่า Array เช็คใน ฐานข้อมูล php myadmin ก็ขึ้น Array เหมือนกันครับ จะต้องแก้ไขอย่างไรครับ ไฟล์ save อยู่ด้านบนกระทู้ครับ

อัพโหลดภาพ และฟอร์มรายละเอียด

ไฟล์ภาพขึ้น แต่รายละเอียดภาพ ขึ้นว่า Array

ฐานข้อมูลบ Appsrve

gallery_list Code (PHP)
 <td>
<?
			  include ("class_dethai.php"); 
include("conn.php");
		$sql = "SELECT * FROM album WHERE ID_album = '".$_GET["ID_album"]."' ";
		$query = mysql_query($sql) or die ("Error Query [".$sql."]");
		$result = mysql_fetch_array($query);
?>
              </p>
			    <p><?php echo $result["ID_album"];?><br />
  <img src="myfile/<?php echo $result["Picture_pic"];?>" width="180" height="120" /></p></td>
            </tr>
            <tr>
              <td width="249" align="right">ชื่ออัลบั้ม</td>
              <td width="776">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                <?=$result["Name_pic"];?></td>
            </tr>
            <tr>
              <td align="right">รายละเอียด</td>
              <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      &nbsp;
                <?=$result["Detail_pic"];?></td>
            </tr>
            <tr>
              <td align="right">วันที่</td>
              <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;
                <? $strDate = $result["Date_pic"];
     echo DateThai($strDate);?></td>
            </tr>
            <tr>
              <td colspan="2" align="right">&nbsp;</td>
            </tr>
            <tr>
              <td colspan="2"><?

		$sql2 = "SELECT * FROM picture WHERE ID_album = '".$_GET["ID_album"]."' ORDER BY ID_album ASC ";
		$query2 = mysql_query($sql2) or die ("Error Query [".$sql2."]");

		echo"<table border=\"0\"  cellspacing=\"0\" cellpadding=\"0\"  align=\"center\" ><tr>";
		$intRows = 0;
		while($result2 = mysql_fetch_array($query2))
		{
			echo "<td>"; 
			$intRows++;
	?>
                <table width="245"  height="170" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td align="center"><p><a href="gallery/<?=$result2["GalleryShot"];?>" rel="lightbox[roadtrip]" 
        title="<?=$result2["GalleryShot"];?>"><img src="gallery/<?=$result2["GalleryShot"];?>" alt="" width="150" height="100" /></a>
         <a href="gallery_delete.php?ID_pic=<?=$result2["ID_pic"]; echo "&ID_album=",$_GET["ID_album"];?>" onclick="return confirm('คุณต้องการที่จะลบข้อมูลหรือไม่')">ลบ</a>
                      <?=$result2["GalleryShot"];?>
                      <br />
                      <?=$result2["Detail_img"];?>
                      <br />
                    <? $strDate = $result2["Date_img"];
     echo DateThai($strDate);?>
                    </p></td>
                  </tr>
                </table>
                <?
			echo"</td>";
			if(($intRows)%3==0)
			{
				echo"</tr>";
			}
		}
		echo"</tr></table>";

		mysql_close();
	?></td>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-12-08 14:16:03 By : godzaa
 


 

No. 4



โพสกระทู้ ( 2,311 )
บทความ ( 1 )



สถานะออฟไลน์


ต้องเช็คตรงบันทึกลง DB อ่ะครับ ลอง Debug ค่าแต่ละตัวดูว่ารับค่ามาถูกต้องรึป่าว แต่ข้างล่างนี้ผมเห็นบันทึกแค่ 2 ฟิลด์นะครับ
Code
$sql = "INSERT INTO picture (ID_album,GalleryShot) VALUES ('$ID_album','{$Filename}');";

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-12-08 15:06:17 By : arm8957
 


 

No. 5



โพสกระทู้ ( 23 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

Code (PHP)
<?php 
 include("class_dethai.php");
include ("class.imagesize.php"); 
include("conn.php");
$ID_album=$_POST[ID_album]; 
$name =$_POST[txtname];
$detail=$_POST[txtdetail];
$date1=$_POST[datepicker];

if(isset($_POST['Submit'] )) 
{ 
    $num_file = count($_FILES['file']['name']); 
    $select = false; 
    $count = 0; 
    for($i = 0; $i < $num_file ; $i++) //เนื่องจาก upload แบบ array เราจึงใช้ loop จัดการทีละไฟล์ 
    { 
        if($_FILES['file']['error'][$i] != 0) //ถ้าเกิดข้อผิดพลาดให้ข้ามไฟล์นนี้ไป 
        { 
            $count++; 
            continue; 
        } 
        if($_FILES['file']['name'][$i] != "") 
        { 
            $Filename = $_FILES['file']['name'][$i]; 
            $type = $_FILES['file']['type'][$i]; 
              //เก็บชื่อไฟล์เป็นเวลาขณะที่ upload แล้วตามด้วยนามสกุลไฟล์ ถ้าไฟล์มีชื่อเหมือนกันจะได้ไม่มีปัญหา 
          //สามารถ upload ไฟล์นามสกุล .gif, .png, .jpg, .zip, .docx, .pdf, .doc, .swf, .rar ได้ 
            $time = time() * microtime(); 
            if ( $type == "image/gif" ) {$Filename = $time.".gif"; $pic_type = 'GIF'; } 
            else if ( $type == "image/png" ) {$Filename = $time.".png"; $pic_type = 'PNG'; } 
            else if (( $type == "image/jpg") or ($type=="image/jpeg") or ($type == "image/pjpeg")){$Filename= $time.".jpg"; $pic_type = 'JPG'; } 
            else if ($type == "application/octet-stream" ) {$Filename = $time.".zip"; $pic_type = false;} 
            else if ($type == "application/vnd.openxmlformats-icedocument.wordprocessingml.document" ) {$Filename = $time.".docx"; $pic_type = false;} 
            else if ($type == "application/pdf" ) {$Filename = $time.".pdf"; $pic_type = false;} 
            else if ($type == "application/msword" ) {$Filename = $time.".doc"; $pic_type = false;} 
            else if ($type == "application/x-shockwave-flash" ) {$Filename = $time.".swf"; $pic_type = e;} 
            else if ($type == "application/octet-stream" ) {$Filename = $time.".rar"; $pic_type = false;} 
            //move ไฟล์ไปยังโฟลเดอร์ที่สร้างไว้ในที่นี้คือ fileupload 
            if(move_uploaded_file($_FILES['file']['tmp_name'][$i], 'gallery/'.$Filename)){ 
            //โค้ดในส่วนของการลดขนาดไฟล์รูปภาพ 
                if($pic_type){ 
                    $original_image = "gallery/" . $Filename ;  
                    $size = getimagesize($original_image); //ดึงขนาดของไฟล์ภาพมา 
                    $desired_height = 500 ; 
                    $desired_width = round($desired_height*$size[0]/$size[1]);
                    $image = new hft_image($original_image); 
                    $image->resize($desired_width, $desired_height, '0'); 
                    $image->output_resized("gallery/".$Filename, "JPG"); 
                } 
                //จัดเก็บชื่อไฟล์ลงฐานข้อมูล 
$sql = "INSERT INTO picture (ID_album,GalleryName,GalleryShot,Detail_img,Date_img) VALUES ('$ID_album','$name ','{$Filename}','$detail','$date1');";
$rc = mysql_query($sql);
		 } 

        }else{ 
            $count++; 
        } 
    } 
echo "บันทุึกข้อมูลเรียบร้อยแล้วครับ"; 
echo '<meta http-equiv="refresh" content="2;url=view_album.php">';
}else{ 

    echo "คุณยังไม่ได้เลือกไฟล์ Upload"; 
} 
?>


ลองรับค่ามาแล้วครับ ก็ยังขึ้น ค่า Array ครับ มีวิธิไหนที่ช่วยได้ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-12-20 10:56:13 By : godzaa
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ผมสร้างไฟล์อัพโหลดรูปภาพ พร้อมฟอร์มรายละเอียดข้อความหลายภาพ แต่อยากให้ อัพโหลดได้ทั้งหมด ในปุ่ม Submit ปุ่มเดียว ต้องทำอย่างไรครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 00
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่