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 > upload image with php การอัปโหลดรูปภาพเก็บในฐานข้อมูล



 

upload image with php การอัปโหลดรูปภาพเก็บในฐานข้อมูล

 



Topic : 051822



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



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




การอัปโหลดรูปภาพเก็บในฐานข้อมูล มีวิธีทำ 2 วิธี คือ

อัปโหลดเป็นรูปภาพเก็บไว้ในโฟลเดอร์ แล้วเก็บชื่อภาพไว้ในฐานข้อมูล
อัปโหลดรูปภาพอัดลงไปในฐานข้อมูลเลย
ทั้งสองวิธีนี้ต่างมีข้อดีและข้อเสีย

วิธีที่ 1 ข้อดีคือ ฐานข้อมูลไม่บวม เพราะเก็บเฉพาะชื่อรูปภาพเท่านั้น ส่วนข้อเสียคือ โฟลเดอร์ที่ใช้เก็บรูปภาพ ต้องกำหนด permission เป็น 0777 เขียนและอ่านได้ ซึ่งในบางสภาพแวดล้อม เป็นเรื่องที่ลำบาก โดยเฉพาะกับโฮสต์ที่เป็นวินโดว ต้องติดต่อ admin ให้ช่วย ช่างวุ่นวาย

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

จะกล่าวถึงวิธีที่ 1 ก่อน
ผมขอแนะนำคลาสตัวหนึ่งชื่อ class.upload.php ผมใช้อยู่ อันที่จริง php มีคำสั่งจัดการรูปภาพอยู่นะ แต่ผมว่าใช้โค้ดที่คนอื่นเขียนแจกไว้แล้ว คล่องกว่า

ซึ่ง class.upload.php นี้ ความสามารถสูงส่ง ทั้งใช้ง่าย ความสามารถโดยคร่าวๆ นะ

สามารถ ย่อ ขยาย ภาพ
สามารถ เพิ่มลายน้ำเข้าไปในรูปภาพ
สามารถ เพิ่มโลโก้ซ้อนเข้าไปในภาพ
สามารถ คร้อปภาพ
เพิ่มแสง เพิ่มเงา พิมตัวอักษร เข้าไปในรูปภาพ
และอื่นๆ อีกเพียบ ซึ่งเขามี help ให้อ่านในเว็บ
ดาวน์โหลด class.upload.php ที่ http://www.verot.net/php_class_upload_download_zip.htm

อ่าน help เพิ่มเติมที่ http://www.verot.net/res/sources/class.upload.html

โครงสร้างฐานข้อมูลในตัวอย่าง
Code (PHP)
– —————————-
– TABLE structure FOR tbl_image
– —————————-
CREATE TABLE `tbl_image` (
`image_id` tinyint(4) UNSIGNED NOT NULL AUTO_INCREMENT,
`image_name` varchar(50) NOT NULL COMMENT ‘จัดเก็บชื่อรูปภาพ’,
 
PRIMARY KEY (`image_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
 
– —————————-



ตัวอย่างโค้ด :

Code (PHP)
<?php
// Include คลาส class.upload.php เข้ามา เพื่อจัดการรูปภาพ
require_once('class/class.upload.php') ;
 
// ส่วนกำหนดการเชื่อมต่อฐานข้อมูล
$hostname_connection = "localhost";
$database_connection = "db_test";
$username_connection = "root";
$password_connection = "";
$connection = mysql_pconnect($hostname_connection, $username_connection, $password_connection)
		or trigger_error(mysql_error(),E_USER_ERROR); 
mysql_query( "SET NAMES UTF8" ) ;
 
 
//  ถ้าหากหน้านี้ถูกเรียก เพราะการ submit form  
//  ประโยคนี้จะเป็นจริงกรณีเดียวก็ด้วยการ submit form 
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
 
    // เริ่มต้นใช้งาน class.upload.php ด้วยการสร้าง instant จากคลาส
    $upload_image = new upload($_FILES['image_name']) ; // $_FILES['image_name'] ชื่อของช่องที่ให้เลือกไฟล์เพื่ออัปโหลด
 
    //  ถ้าหากมีภาพถูกอัปโหลดมาจริง
    if ( $upload_image->uploaded ) {
 
        // ย่อขนาดภาพให้เล็กลงหน่อย  โดยยึดขนาดภาพตามความกว้าง  ความสูงให้คำณวนอัตโนมัติ
        // ถ้าหากไม่ต้องการย่อขนาดภาพ ก็ลบ 3 บรรทัดด้านล่างทิ้งไปได้เลย
        $upload_image->image_resize         = true ; // อนุญาติให้ย่อภาพได้
        $upload_image->image_x              = 400 ; // กำหนดความกว้างภาพเท่ากับ 400 pixel 
        $upload_image->image_ratio_y        = true; // ให้คำณวนความสูงอัตโนมัติ
 
        $upload_image->process( "upload_images" ); // เก็บภาพไว้ในโฟลเดอร์ที่ต้องการ  *** โฟลเดอร์ต้องมี permission 0777
 
        // ถ้าหากว่าการจัดเก็บรูปภาพไม่มีปัญหา  เก็บชื่อภาพไว้ในตัวแปร เพื่อเอาไปเก็บในฐานข้อมูลต่อไป
        if ( $upload_image->processed ) {
 
            $image_name =  $upload_image->file_dst_name ; // ชื่อไฟล์หลังกระบวนการเก็บ จะอยู่ที่ file_dst_name
            $upload_image->clean(); // คืนค่าหน่วยความจำ
 
            // เก็บชื่อภาพลงฐานข้อมูล
            $insertSQL = sprintf("INSERT INTO tbl_image (image_name) VALUES ( '%s' )", $image_name );
            echo $insertSQL ;
            mysql_select_db($database_connection, $connection);
            $Result1 = mysql_query($insertSQL, $connection) or die(mysql_error());
 
 
        }// END if ( $upload_image->processed )
 
    }//END if ( $upload_image->uploaded )
 
 
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upload Image To Database</title>
</head>
 
<body>
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
  <p>Image_name 
    <input name="image_name" type="file" id="image_name" size="40" />
  </p>
  <p>
    <input type="submit" value="Upload" />
    <input type="hidden" name="MM_insert" value="form1" />
  </p>
</form>
</body>
 
</html>


เครดิต : เว็บ select2web.com ขอบคุณสำหรับ การแบ่งบัน เลยนำมาแบ่งบันเพื่อนๆ คะ สังคมแห่งการแบ่งบันความรู้ พอดีว่าำกำลังทำโค้ด เลยนำตัวอย่างมาฝากคะ จะไ้ด้ศึกษา หลายๆตัวอย่างคะ



Tag : PHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2010-11-18 11:03:38 By : yiyaying View : 41620 Reply : 13
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

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

ตัวอย่างเพิ่มเติมใน thaicreate.com ครับ


Go to : PHP Uploads Files To MySQL

Go to : PHP MySQL Multiple Upload File to MySQL - CreateElement Input File Upload






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-11-18 11:34:36 By : webmaster
 


 

No. 2



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



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


ตอบความคิดเห็นที่ : 1 เขียนโดย : webmaster เมื่อวันที่ 2010-11-18 11:34:36
รายละเอียดของการตอบ ::
ขอบคุณ สำหรับตัวอย่างเพิ่มเติม คะ คุณ Mr.win

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-11-18 11:42:49 By : yiyaying
 

 

No. 3



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



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

ขอบคุณ คุณ nutvaree ครับ ที่นำความรู้ดีๆมาบอกกัน
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-12-14 12:28:43 By : mike_gt3
 


 

No. 4



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



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


ขอบคุณค่ะสำหรับความรู้จะลองเอาไปประยุกต์ค่ะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-06-06 14:18:32 By : rotchana
 


 

No. 5

Guest


ผมรบกวนสอบถามหน่อยน่ะคัรบ เพิ่งหัดเขียนครับ จากโค๊ดด้านบน ที่เป็น class วางตรงจุดไหนก้ได้เหรอครับผมกลัวผิดตำแหน่งอ่ะครับ
ถ้าจาก code ผมแล้ว ควรวางตรงไหนได้ครับ ถ้าโค๊ดจากข้างบนน่ะครับ เฉพาะตรง class อ่ะครับ

อันนี้จากโค๊ดผมครับ

Code (PHP)
<?php
include("top.php")
?>

<?php
$student_no =  $_SESSION['user_no'] ;
$user_type  = $_SESSION['user_type'] ;



?>
<!--#include file  = "top.php" -->
<script language="VBScript" type="text/VBScript">
		Function FrmOK()
			Dim TheForm
 			Set TheForm =  Document.Form1
			TheForm.submit
		End Function
	
	Function FrmCancel()
			Dim TheForm
 			Set TheForm =  Document.Form2
			TheForm.submit
		End Function
</script>

  <tr> 
    <td colspan="24"><table width="100%" height="351" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td valign="top" background="images/template_edit_2_23.gif" bgcolor="#FFFFCC"> 
		  
		  <?php 
		  
		  if  (  $user_type  == 5  ){
		  ?>
            <table width="995" border="0" cellpadding="0" cellspacing="0" bordercolor="#000000">
              <tr> 
                <td width="132">&nbsp;</td>
                <td width="739" valign="top"><div align="right" class="text1"></div></td>
                <td width="124" valign="top">&nbsp;</td>
              </tr>
              <tr> 
                <td>&nbsp;</td>
                <td valign="top"> 
                  <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr bgcolor="#9900CC" class="text9"> 
                      <td width="100%" colspan="4" bgcolor="#3333FF" class="text9"><div align="center" class="text1"> 
                          <p class="text10">เพิ่มข่าวประชาสัมพันธ์ในโรงเรียน</p>
                        </div></td>
                    </tr>
                    <tr class="text9"> 
                      <td class="text13">&nbsp;</td>
                    </tr>
                    <tr align="center" class="text9"> 
                      <td class="text13"> <div align="center">
					  	<form name="form1" method="post" action="show_list_activity_news.php">
                          <table width="100%" border="0">
                            <tr class="text22"> 
                              <td width="9%"><div align="center"> 
                                    <p class="text23">
                                      <input type="hidden" name="add_status" value="1">
								
                                    </p>
                                </div></td>
                              <td width="28%"><div align="center"> 
                                  <p align="right" class="text23">วันเดือนปี</p>
                                </div></td>
                              <td width="2%"><div align="left"> 
                                  <p>&nbsp;&nbsp;&nbsp;&nbsp;<span class="text23">&nbsp;&nbsp;</span></p>
                                </div></td>
                              <td width="61%"> 
                                <?php
								
								$today = getdate();
							  			$mon =   $today['mon'];
										$year =  $today['year'];
										$day =  $today['mday'];
							  
				
							  
							  ?>
                                <select name="select_day">
                                  <?php for ($i = 1; $i <= 31; $i++) { ?>
                                  <option value="<?php echo $i  ;?>"  <?php   if($i==$day ){ echo " selected " ;}?> ><?php echo $i?></option>
                                  <?php } ?>
                                </select> 
                                <?php  $month_name = array("","มกราคม","กุมภาพันธ์","มีนาคม" ,"เมษายน" ,"พฤษภาคม" ,"มิถุนายน","กรกฎาคม"  ,"สิงหาคม" ,"กันยายน" ,"ตุลาคม" ,"พฤศจิกายน","ธันวาคม" ) ?>
                                <select name="select_month">
                                  <?php for ($i = 1; $i <= 12; $i++) { ?>
                                  <option value="<?php echo $i  ;?>"  <?php   if($i==$mon ){ echo " selected " ;}?> ><?php echo  $month_name[$i]?></option>
                                  <?php } ?>
                                </select> <select name="select_year">
                                  <?php for ($i = $year-5; $i <= $year+5; $i++) { ?>
                                  <option value="<?php echo $i  ;?>"  <?php   if($i==$year ){ echo " selected " ;}?> ><?php echo  chang_year($i )?></option>
                                  <?php } ?>
                                </select> </td>
                            </tr>
                          
                           
                            <tr> 
                              <td>&nbsp;</td>
                              <td><div align="right"> 
                                    <p class="text23">หัวข้อข่าว</p>
                                </div></td>
                              <td>&nbsp;</td>
                              <td> <div align="left"> 
                                  <input name="activity_news_head" type="text" size="50" value="">
                                </div></td>
                            </tr>
                            <tr> 
                              <td>&nbsp;</td>
                              <td class="text23"><div align="right">รายละเอียดข่าว</div></td>
                              <td>&nbsp;</td>
                              <td> <textarea name="activity_news_detial" cols="49" rows="10" ></textarea> 
                              </td>
                            </tr>
                            <tr> 
                              <td>&nbsp;</td>
                              <td class="text23">&nbsp;</td>
                              <td>&nbsp;</td>
                              <td>&nbsp;</td>
                            </tr>
                            <tr> 
                              <td colspan="4"> <div align="center"> 
                                  <input type="button" name="Button" value="บันทึก"  onClick= FrmOK()>
                                  <input type="button" name="Submit2" value="ยกเลิก"  onClick=  FrmCancel()>
                                </div></td>
                            </tr>
                            <tr>
                              <td colspan="4">
							  
                            
								</td>
                            </tr>
                            <tr>
                              <td colspan="4">&nbsp;</td>
                            </tr>
                            <tr>
                              <td colspan="4">&nbsp;</td>
                            </tr>
                          </table>
						  </form>
                        </div></td>
                    </tr>
                    <tr class="text9"> 
                      <td class="text12">
					  <form name="form2" method="post" action="show_list_activity_news.php">
                          <input type="hidden" name="add_status" value="0">
                        </form>
					  &nbsp;</td>
                    </tr>
                    <tr class="text9"> 
                      <td class="text12"><div align="center" class="text13"></div>
                        <div align="center"></div></td>
                    </tr>
                  </table>
                  <div align="left"></div></td>
                <td valign="top">&nbsp;</td>
              </tr>
            </table>
			<?php
			}
			
			?>
            <div align="right"></div>
            <div align="center"></div></td>
        </tr>
      </table> </td>
  </tr>
  	  <?php

include("bottom.php")

?>
  <!--#include file  = "bottom.php" -->

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-17 13:36:45 By : itsup
 


 

No. 6



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



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


วางไว้ข้างบนก็ได้ครับ ตรง include('top.php'); อ่ะ

อ่านการใช้งานตามคู่มือเลยครับ --> คลิก


ประวัติการแก้ไข
2013-12-17 13:49:40
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-17 13:48:28 By : arm8957
 


 

No. 7

Guest


ครับขอบคุณครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-17 14:10:37 By : itsup
 


 

No. 8

Guest


จากข้างบนผมทำตามหมดแล้วครับ แต่ปัญหาคือเมือเราอัพโหลดรูปแล้วน่ะครับ ตำแหน่งของรูปจะไปอยู่หน้าที่เราต้องการได้หรือเปล่าครับ
จากที่ผมทำประกาศข่าวได้แต่ต้องเพิ่มรูปด้วยน่ะครับ จากหน้าไฟล์ของผมครับ

class1



ผมไม่เข้าใจครับว่าถ้าอัพโหลดแล้วห้มาอยู่ในห้นานี้จะทำอย่างไหรครับ

class2


จากโค๊ดหน้าที่ 2 ครับ

Code (PHP)
<td>
<?php
include("top.php")
?>

<?php
$student_no =  $_SESSION['user_no'] ;
$user_type  = $_SESSION['user_type'] ;

// delete data 
// ลบข้อมูลกิจกรรม
$del_status = $_POST['del_status'];
if ($del_status==1){
$query = "DELETE FROM  activity_news  WHERE  activity_news_id= " .    $_POST['activity_news_id']  . "";
//$query = "DELETE FROM  activity_news  WHERE  activity_news_id= 5";
$result_id    =  db_query ($query, $link_id = 0);
//echo $_POST['activity_news_id'] ;
}

// edit data
// แก้ไขข้อมุลกิจกรรม
$edit_status = $_POST['edit_status'];
if ($edit_status==1){
	 if (trim($_POST['activity_news_head'] ) !=""){
     $query = "UPDATE activity_news   SET activity_news_day= ".  $_POST['select_day']  . ", activity_news_month= ".  $_POST['select_month']  . ", activity_news_year= ".  $_POST['select_year']  . ",activity_news_head= '".  $_POST['activity_news_head']  . "' ,activity_news_detial='"  .   $_POST['activity_news_detial'] . "' WHERE activity_news_id =" .   $_POST['activity_news_id'] .  "";

	 $result_id    =  db_query ($query, $link_id = 0);
	// echo$_POST['activity_news_head']  ;
   }
}

// add data
// เพิ่มข้อมุลกิจกรรม
$add_status = $_POST['add_status'];
if ($add_status==1){
  if (trim($_POST['activity_news_head'] ) !=""){
  		
			$query= "select * from activity_news where activity_news_day = ".  $_POST['select_day']." and activity_news_month ="   . $_POST['select_month']  . " and activity_news_year = "   .  $_POST['select_year'] .  " and activity_news_head= '"  .  $_POST['activity_news_head']  . "' and activity_news_detial  =  '"  . $_POST['activity_news_detial']    .  "'";
			$result_id    =  db_query ($query, $link_id = 0);
			$rows  =  db_num_rows ($result_id);
			
			if ($rows <= 0)
			{
						$query= "INSERT INTO activity_news(activity_news_day, activity_news_month, activity_news_year, activity_news_head,  activity_news_detial) VALUES(" .$_POST['select_day'] . "," . $_POST['select_month'] . "," . $_POST['select_year'] . ", '" . $_POST['activity_news_head']   .  "', '"   .  $_POST['activity_news_detial']  .  "')";
						$result_id    =  db_query ($query, $link_id = 0);
						//echo $_POST['activity_news_head'];
			}
 }
}

// เลือกข้อมูลที่ต้องการแสดง
$query = "select * from activity_news order by activity_news_id desc";
$result_id    =  db_query ($query, $link_id = 0);
?>
<!--#include file  = "top.php" -->

<script language="VBScript" type="text/VBScript">
		Function FrmOK()
			Dim TheForm
 			Set TheForm =  Document.Form1
			TheForm.submit
		End Function
	
	Function FrmCancel()
			Dim TheForm
 			Set TheForm =  Document.Form2
			TheForm.submit
		End Function
</script>
  <tr> 
    <td colspan="24"><table width="100%" height="351" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td valign="top" background="images/template_edit_2_23.gif" bgcolor="#FFFFCC"> 
		  
		  <?php 
		  
		  if  (  $user_type  == 5  or $user_type  == 7 or $user_type  == 8  ){
		  ?>
            <table width="995" border="0" cellpadding="0" cellspacing="0" bordercolor="#000000">
              <tr> 
                <td width="132">&nbsp;</td>
                <td width="739" valign="top"><div align="right" class="text1"><a href="menu_user.php">กลับสู่เมนูหลัก</a></div></td>
                <td width="124" valign="top">&nbsp;</td>
              </tr>
              <tr> 
                <td>&nbsp;</td>
                <td valign="top"> 
                  <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr bgcolor="#9900CC" class="text9"> 
                      <td width="100%" colspan="4" bgcolor="#3333FF" class="text9"><div align="center" class="text1"> 
                          <p class="text10">รายการข่าวประกาศ</p>
                        </div></td>
                    </tr>
                    <tr class="text9"> 
                      <td class="text13">&nbsp;</td>
                    </tr>
                    <tr align="center" class="text9"> 
                      <td class="text13"> <div align="center"> 
                          <table width="100%" border="0">
                            <tr class="text22"> 
                              <td width="7%"><div align="center"> 
                                  <p class="text23">ลำดับที่</p>
                                </div></td>
                              <td width="10%"><div align="center"> 
                                  <p class="text23">วันเดือนปี</p>
                                </div></td>
                              <td width="40%"><div align="left"> 
                                  <p>&nbsp;&nbsp;&nbsp;&nbsp;<span class="text23">&nbsp;&nbsp;กิจกรรม</span></p>
                                </div></td>
                              <td width="10%">&nbsp;</td>
                              <td width="10%">&nbsp;</td>
                              <td width="10%">&nbsp;</td>
                            </tr>
                            <?php
							$i=1;
									while($row =  db_fetch_row ($result_id))
									{
									// แสดงข้อมูลข่าวกิจกรรม
							?>
                            <tr> 
                              <td><div align="center"><?php echo  $i;?> </div></td>
                              <td> <div align="center"> <?php echo  $row[3] ."-".$row[4]."-". chang_year($row[5] )  ;?></div></td>
                              <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo  $row[1];?></td>
                              <td>&nbsp;</td>
                              <td><div align="center"><a href="edit_activity_news.php?activity_news_id=<?php echo   $row[0]?>">แก้ไข</a></div></td>
                              <td><div align="center"><a href="del_activity_news.php?activity_news_id=<?php echo   $row[0]?>">ลบ</a></div></td>
                            </tr>
                            <?php
							$i++;
							}
							?>
                            <tr> 
                              <td>&nbsp;</td>
                              <td>&nbsp;</td>
                              <td>&nbsp;</td>
                              <td colspan="3">&nbsp;</td>
                            </tr>
                            <tr> 
                              <td>&nbsp;</td>
                              <td>&nbsp;</td>
                              <td>&nbsp;</td>
                              <td colspan="3"><div align="right"><a href="add_activity_news.php">เพิ่มข่าว</a></div></td>
                            </tr>
                          </table>
                        </div></td>
                    </tr>
                    <tr class="text9"> 
                      <td class="text12">&nbsp;</td>
                    </tr>
                    <tr class="text9">
                      <td class="text12">
					
						</td>
                    </tr>
                    <tr class="text9"> 
                      <td class="text12">&nbsp;</td>
                    </tr>
                    <tr class="text9"> 
                      <td class="text12">&nbsp;</td>
                    </tr>
                    <tr class="text9"> 
                      <td class="text12"><div align="center" class="text13"></div>
                        <div align="center"></div></td>
                    </tr>
                  </table>
                  <div align="left"></div></td>
                <td valign="top">&nbsp;</td>
              </tr>
            </table>
			<?php
			}
			
			?>
            <div align="right"></div>
            <div align="center"></div></td>
        </tr>
      </table> </td>
  </tr>
  	  <?php

include("bottom.php")

?>
  <!--#include file  = "bottom.php" -->

</td>


จะทำอย่างไหรดีครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-17 14:20:17 By : itsup
 


 

No. 9

Guest


ผมลองทดสอบแล้วคับ ทำการ upload เข้า data base แล้วตามภาพน่ะครับ

cpic


แต่ปัญหาคือผมจะดึงเข้ามาหน้านี้ได้อย่างไหรครับ รบกวนช่วยดูทีครับ
จากหน้าข่าวที่ผมได้เคยโพสต์ไล้วน่ะครับตอนแสดงข่าวน่ะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-17 15:48:03 By : itsup
 


 

No. 10



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



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


ในตาราง tbl_images เพิ่มอีกฟิลด์นึงเพื่อเก็บ id ของบทความหรือกระทู้ครับ เวลาดึงภาพมาโชว์ก็ WHERE forum_id ครับ (น่าจะนึกภาพออกนะครับ)
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-17 15:58:21 By : arm8957
 


 

No. 11



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



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



แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-17 16:03:17 By : kitisak053
 


 

No. 12



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



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


ผมอัพโหลด CSV ไม่ฟ้องerror ครับ ...แต่ทำไมมันไม่เข้า database อ่ะ echo ก็แล้วนะครับ

ets1
ets2

ets3
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-03-03 15:25:39 By : ศิวกร
 


 

No. 13



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



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


อันดับแรก เช็คดูครับว่าโครงสร้างคำสั่ง INSERT คุณเขียนถูกหรือเปล่า? โดยปกติแล้วมันไม่น่าจะมี WHERE... อะไรนะครับ
2. แนะนำให้ตั้งกระทู้ใหม่ครับ
3. อย่าแคปหน้าจอในส่วนของโค้ด เพราะคนที่มาตอบส่วนใหญ่ขี้เกียจพิมพ์(รวมถึงผมด้วย) เลยทำให้ขี้เกียจตอบ
4. เอาโค้ดมาวางเลย โดยใช้รูปแบบแสดงผลแบบ PHP Code ที่ admin เค้าจัดบริการไว้ให้เพื่อให้ดูง่าย และไล่โค้ดได้ง่าย
5. ลอง debug error ดูการทำงานแต่ละส่วนดูครับ
5.1. debug ในส่วนของการอ่านข้อมูลจากไฟล์ CSV และ Debug ในส่วนของการ Query ได้แก่
Code (PHP)
#...โค้ดด้านบนของคุณ ...

while($objArr = ......){
print_r($objArr); #ลองดูว่าข้อมูลสามารถอ่านได้หรือไม่

....โค้ดในส่วนของ INSERT....
$objQuery = mysql_query($strSQL) or die(mysql_error()); #ดูว่าสามารถ query ได้หรือไม่?
}


ก็ประมาณนี้
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-03-03 16:01:15 By : arm8957
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : upload image with php การอัปโหลดรูปภาพเก็บในฐานข้อมูล
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 อัตราราคา คลิกที่นี่