|
 |
|
แก้ไขฟิลด์รุปภาพแล้วค่าที่ส่งมาเป็นค่าว่างค่ะ ช่วยหน่อยนะคะ |
|
 |
|
|
 |
 |
|
เอาแบบง่ายๆ เลยนะครับ
----------------------------
ตอนที่แก้ไขแล้วเรากดบันทึกนะครับ ในหน้าที่เรา update (sql) เราต้องเช็คก่อนว่ามีการอัพรูปมาหรือเปล่าครับ ถ้าไม่มีก็ไม่ต้อง update ฟิลด์รูปภาพครับ โดยใช้คำสั่ง is_uploaded_file ในการตรวจสอบการอัพโหลดรูปมาหรือเปล่าครับ
https://www.thaicreate.com/php-manual/function.is-uploaded-file.html
|
 |
 |
 |
 |
Date :
2012-03-18 10:12:14 |
By :
bshtraining |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อันนี้ใช้ได้กับภาพที่เราเก็บแต่ชื่อในฐานข้อมูลหรือเปล่าคะ
|
 |
 |
 |
 |
Date :
2012-03-18 10:18:31 |
By :
ข้าวหอมมะลิ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เช็คแล้วไม่มีการส่งค่าเลยค่ะ
|
 |
 |
 |
 |
Date :
2012-03-18 10:47:31 |
By :
toryairuk |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทำไมตอบกระทุ้ไม่ได้นะ
|
 |
 |
 |
 |
Date :
2012-03-18 11:11:10 |
By :
ข้าวหอมมะลิ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใช้กับชื่อรูปภาพที่เก็บในฐานข้อมูลครับ
ในเรื่องที่บอกว่าเช็คแล้วไม่มีการส่งค่า ตรงนี้หมายถึงว่า ตรวจเช็คจาก is_uploaded_file ว่าไม่มีการส่งค่าถูกไหมครับ ถ้าใช่ก็เอาตรงนี้หละครับมาเป็นเงื่อนไขในการ update ครับ จัด update คนละชุดก็ได้ครับ เช่น
member
---------------------
idmember
membername
imgmember
Code (PHP)
if (is_uploaded_files($_FILES["ชื่อฟิลด์รูปภาพ"]["tmp_name"]))
$sqlupdate = "UPDATE ชื่อตาราง SET idmember = 'ค่า', membername = 'ค่า', imgmember = 'ค่า' WHERE (idmember = 'ค่า')";
else
$sqlupdate = "UPDATE ชื่อตาราง SET idmember = 'ค่า', membername = 'ค่า' WHERE (idmember = 'ค่า')";
ประมาณนี้ครับ (ผมว่าเป็นวิธีที่เข้าใจง่ายสุดแล้วครับ ยังมีวิธีอื่นอีกเยอะ แต่ผมแนะนำอันนี้ครับ)
|
 |
 |
 |
 |
Date :
2012-03-18 11:29:56 |
By :
bshtraining |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คือ หนูเอาโพสมาลงไม่ได้ค่ะพี่ แต่ถ้าโพสปกติน่ะได้ค่ะ
|
 |
 |
 |
 |
Date :
2012-03-18 12:18:04 |
By :
toryairuk |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Error ว่าอะไรครับ
|
 |
 |
 |
 |
Date :
2012-03-18 12:24:57 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่มีError ค่ะ แต่ที่achoดู เค้าบอกว่าฟิลด์pictureไม่มีค่าค่ะ
|
 |
 |
 |
 |
Date :
2012-03-18 12:27:27 |
By :
toryairuk |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองเช็คตัวแปรที่รับค่าจากหน้าที่แล้วครับ ในส่วนของรูปภาพนะครับ เวลารับเราไม่ใช้ $_POST หรือ $_GET นะครับ เราใช้ $_FILES["ชื่อฟิลด์"]["name"] ตัวนี้แทนครับ
|
ประวัติการแก้ไข 2012-03-18 14:02:37
 |
 |
 |
 |
Date :
2012-03-18 14:00:20 |
By :
bshtraining |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองทำดูแล้วก็เหือนเดิมคะ่
|
 |
 |
 |
 |
Date :
2012-03-18 14:11:12 |
By :
toryairuk |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แก้ได้แล้วค่ะ ขอบคุณนะคะ
|
 |
 |
 |
 |
Date :
2012-03-18 15:49:25 |
By :
toryairuk |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|