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 > ช่วยด้วยครับ ลงรูปภาพไปใน mysql ไม่ได้ อย่างอื่นเข้าหมดยกเว้นไฟล์รูปครับ



 

ช่วยด้วยครับ ลงรูปภาพไปใน mysql ไม่ได้ อย่างอื่นเข้าหมดยกเว้นไฟล์รูปครับ

 



Topic : 131579



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



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




pcituCode (PHP)
<?
ob_start();
session_start();
if($_SESSION["adminlogin"]=="")
{
header('location:index.php');
exit();
}
//============ Start Session และทำการเรียก Function ติดต่อฐานข้อมูล 
require_once('../connect/connect.php');
require_once('../connect/function.php');

//=========== กรณีมีการแก้ไขรายการสินค้า
                       if($_GET["Action"]=="Save")
	                   {
						   //===========  บันทึกข้อมูลสินค้า
	                  $sql_up = "update product set ProductCode='$_POST[txtProductCode]',ProductName='$_POST[txtProductName]',Description='$_POST[txtDescription]',Costunit='$_POST[txtPrice2]',Price='$_POST[txtPrice]',PriceNormal='$_POST[txtPriceNormal]',PriceSend='$_POST[txtPriceSend]',Stock='$_POST[txtStock]',Promotion='$_POST[rdoPromotion]',New='$_POST[rdoNew]' where ProductID='$_GET[ProductID]'";
                      $dbquery_up = mysql_query($sql_up);
					  //echo $sql_up;
					//  exit();
					//===========  แก้ไขไฟล์เล็ก
					                   	if(!empty($file))
                                             {
														$path="../picture";								
														//=========== อัพโหลตไฟลืเล็ก
                                                        @copy( $file ,"$path/$file_name");
                                                       $sql_up = "update product set Picture='$file_name' where ProductID='$_GET[ProductID]'";
                                                        $dbquery_up = mysql_query($sql_up);
								 			 }
										 
					  
									echo"<script language='JavaScript'>";
									echo"alert('แก้ไขข้อมูลเรียบร้อยแล้ว');";
									echo"window.location='editproduct.php?ProductID=$_GET[ProductID]';";
									echo"</script>";					  
			 		  }
					  
?>
<html>
<title>..:: ระบบจัดการฐานข้อมูล ::</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../css/styles.css" type="text/css">
<script language="JavaScript" src="editor.js"></script>
<div align="center"><br>
<?
//===========  อ่านว่าคือสินค้าชนิดใด
$result=select("product","where 1=1 and ProductID='".$_GET["ProductID"]."'");
if(!$result)
{
header("location:product.php");
}

?>
  <table cellspacing=1 cellpadding=4 width="68%" bgcolor=#CCCCCC border=0 align="center" height="10">
    <tbody>
      <tr bgcolor=#e5e5e5> 
        <td width="100%" bgcolor="#FFFFFF"> <div align="center"></div>
          <table cellspacing=1 cellpadding=4 width="100%" border=0 align="center" height="10">
            <tbody>
              <tr bgcolor=#e5e5e5> 
                <td width="35%" bgcolor="#FFFFFF"> <div align="left"><b><img src="../image/allrowto.gif" width="11" height="11" align="absbottom"> 
                    แก้ไขรายการสินค้า</b></div></td>
                <td width="22%" align=middle bgcolor="#FFFFFF"> <div align="left"> 
                  </div></td>
                <td width="43%" bgcolor="#FFFFFF"> <div align="right"><a href="product.php?CatID=<?=$result["CatID"];?>">กลับไป</a></div></td>
              </tr>
            </tbody>
          </table></td>
      </tr>
    </tbody>
  </table>
</div>

<form name="frm<?=$i;?>" method="post" action="<?=$_SERVER['PHP_SELF'];?>?ProductID=<?=$_GET["ProductID"];?>&Action=Save" enctype="multipart/form-data" onSubmit="return checkvalue()">
  <table cellspacing=1 cellpadding=3 width="68%" bgcolor=#CCCCCC border=0 align="center" height="10">
    <tbody>
      <tr bgcolor=#e5e5e5> 
        <td width="31" bgcolor="#FFFFFF"> <script language="Javascript1.2"><!-- // load htmlarea
_editor_url = "";                     // URL to htmlarea files
var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
if (navigator.userAgent.indexOf('Mac')        >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Opera')      >= 0) { win_ie_ver = 0; }
if (win_ie_ver >= 5.5) {
  document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
  document.write(' language="Javascript1.2"></scr' + 'ipt>');  
} else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
// --></script> 




<script language="JavaScript">
function checkvalue()
{

		if(parseInt(document.all.txtPrice2.value) >= parseInt(document.all.txtPrice.value))
		{
		alert('ราคาต้นทุนจะต้องน้อยกว่าราคาพิเศษ');
		document.all.txtPrice2.focus();
		return false;
		}
		if(parseInt(document.all.txtPrice.value) >= parseInt(document.all.txtPriceNormal.value))
		{
		alert('ราคาพิเศษจะต้องน้อยกว่ากว่าราคาปกติ');
		document.all.txtPrice.focus();
		return false;
		}
}
</script>




          <table width="100%" border="0" cellspacing="2" cellpadding="2">
            <tr> 
              <td width="18%">&nbsp;</td>
              <td width="82%">&nbsp;</td>
            </tr>
            <tr> 
              <td valign="top">รหัสสินค้า <font color="#FF0000">** </font></td>
              <td><input name="txtProductCode" type="text" class="txtbox" id="txtProductCode" value="<?=$result["ProductCode"];?>" maxlength="20" readonly> 
              </td>
            </tr>
            <tr> 
              <td valign="top">สินค้าโปรโมชั่น <font color="#FF0000">** </font></td>
              <td><input name="rdoPromotion" type="radio" value="Yes" <? if($result["Promotion"]=="Yes"){?>checked<?}?>>
                ใช่ 
                <input type="radio" name="rdoPromotion" value="No" <? if($result["Promotion"]=="No"){?>checked<?}?>>
                ไม่ใช่</td>
            </tr>
            <tr> 
              <td valign="top">สินค้าใหม่ <font color="#FF0000">** </font></td>
              <td><input name="rdoNew" type="radio" value="Yes" <? if($result["New"]=="Yes"){?>checked<?}?>>
                ใช่ 
                <input type="radio" name="rdoNew" value="No" <? if($result["New"]=="No"){?>checked<?}?>>
                ไม่ใช่</td>
            </tr>
            <tr> 
              <td valign="top">ชื่อสินค้า <font color="#FF0000">** </font></td>
              <td><input name="txtProductName" type="text" class="txtbox" id="txtProductName" style="width:550" value="<?=$result["ProductName"];?>" maxlength="100"></td>
            </tr>
            
 
 
 <tr> 
              <td valign="top">ราคาต้นทุน <font color="#FF0000">** </font></td>
              <td><input name="txtPrice2" type="text" class="txtbox" id="txtPrice2" value="<?=$result["Costunit"];?>" size="10" maxlength="20">
                บาท </td>
            </tr>           
            
            
            
            <tr> 
              <td valign="top">ราคาปกติ <font color="#FF0000">** </font></td>
              <td><input name="txtPriceNormal" type="text" class="txtbox" id="txtPriceNormal" value="<?=$result["PriceNormal"];?>" size="10" maxlength="20">
                บาท </td>
            </tr>
            <tr> 
              <td valign="top">ราคาพิเศษ <font color="#FF0000">** </font></td>
              <td><input name="txtPrice" type="text" class="txtbox" id="txtPrice" value="<?=$result["Price"];?>" size="10" maxlength="20">
                บาท </td>
            </tr>
            <tr>
              <td valign="top">ค่าจัดส่ง</td>
              <td><input name="txtPriceSend" type="text" class="txtbox" id="txtPriceSend" value="<?=$result["PriceSend"];?>" size="10" maxlength="20">
                บาท </td>
            </tr>
            <tr> 
              <td valign="top">จำนวนสินค้า <font color="#FF0000">** </font></td>
              <td><input name="txtStock" type="text" class="txtbox" id="txtStock" value="<?=$result["Stock"];?>" size="10" maxlength="20"></td>
            </tr>
            <tr> 
              <td valign="top">รูปภาพ <font color="#FF0000">** </font></td>
              <td><img src="../picture/<?=$result["Picture"];?>" /></td>
            </tr>
            <tr> 
              <td valign="top">&nbsp;</td>
              <td><input name="file" type="file" class="txtbox" id="file"></td>
            </tr>
            <tr> 
              <td valign="top">รายละเอียด <font color="#FF0000">** </font></td>
              <td><textarea name="txtDescription" cols="40" rows="10" class="txtbox" id="txtDescription" style="width:550; height:450"><?=$result["Description"];?></textarea> 
                <script language="javascript1.2">
editor_generate('txtDescription');
</script> &nbsp;</td>
            </tr>
            <tr> 
              <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
              <td><input name="Submit" type="submit" class="button" value="บันทึก"> 
                <input name="Cancel" type="button" class="button" id="Cancel" value="ยกเลิก" onClick="window.location='product.php?CatID=<?=$result["CatID"];?>';"></td>
            </tr>
            <tr> 
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr> 
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
          </table></td>
      </tr>
  
    </tbody>
  </table>
  <table cellspacing=0 cellpadding=4 width="68%" bgcolor=#CCCCCC border=0 align="center" height="10">
    <tbody>
      <tr bgcolor=#e5e5e5> 
        <td width="100%" bgcolor="#FFFFFF"> <div align="center"></div>
          <table cellspacing=1 cellpadding=4 width="100%" border=0 align="center" height="10">
            <tbody>
              <tr bgcolor=#e5e5e5> 
                <td width="35%" bgcolor="#FFFFFF"> <div align="left"></div></td>
                <td width="22%" align=middle bgcolor="#FFFFFF"> <div align="left"> 
                  </div></td>
                <td width="43%" bgcolor="#FFFFFF"> <div align="right"><a href="product.php?CatID=<?=$result["CatID"];?>">กลับไป</a></div></td>
              </tr>
            </tbody>
          </table></td>
      </tr>
    </tbody>
  </table>
</form>




Tag : PHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2018-07-21 12:52:06 By : TumGrape View : 668 Reply : 2
 

 

No. 1



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



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


คำสั่งรับ ไฟล์รูปภาพคือ $_FILE[] ไม่ใช่ $file

https://www.w3schools.com/php/php_file_upload.asp


อีกเรื่องที่สำคัญ เขียนโค๊ดแบบนี้ไม่มี ความปลอดภัย

ห้ามนำ request string มา รวมกับ sql statement โดยตรง ต้องมีการ escape ข้อมูลก่อน

ป้องกัน sql injection ด้วย

เขียนให้เป็นนิสัย สร้างความชำนาญให้กับตัวเอง แม้จะเป็นโปรแกรมภายในก็ตาม






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2018-07-21 16:08:54 By : Chaidhanan
 


 

No. 2

Guest


แก้ตามคุณ Chaidhanan ยังไม่ได้ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2018-07-21 19:52:01 By : ๊Tumgrape
 

   

ค้นหาข้อมูล


   
 

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