6,252   2 อัปโหลดรูป ครั้งละหลายๆรูปแบบนี้พอจะมีวิธีไหมครับ



phanuwat3291


พลังงานการช่วยเหลือ
( Level 1 )


คะแนนขอบคุณจากสมาชิก
( 0 )


ตอบกระทู้ ( 5 )
เขียนบทความ ( 0 )


ความคิดเห็นที่ 1
อ้างอิงความเห็น


bamossza


พลังงานการช่วยเหลือ
( Level 3 )


คะแนนขอบคุณจากสมาชิก
( 16 )


ตอบกระทู้ ( 112 )
เขียนบทความ ( 28 )

ส่วนของ html ใช้ input tag name ที่เป็น array เข้าช่วยครับ
<input type="file" name="pic[]" accept="image/*" />
<input type="file" name="pic[]" accept="image/*" />
<input type="file" name="pic[]" accept="image/*" />


ส่วน php ก็ใช้ loop เข้าช่วยครับ
// Count # of uploaded files in array
$total = count($_FILES['pic']['name']);

// Loop through each file
for($i=0; $i<$total; $i++) {
   //Get the temp file path
   $tmpFilePath = $_FILES['pic']['tmp_name'][$i];

   //Make sure we have a filepath
   if ($tmpFilePath != ""){
      //Setup our new file path
      $newFilePath = "./uploadFiles/" . $_FILES['pic']['name'][$i];

      //Upload the file into the temp dir
      if(move_uploaded_file($tmpFilePath, $newFilePath)) {

         //success

      }else{

         //fail

      }
   }
}

ลองดูครับไม่ยาก ^___^

ความคิดเห็นที่ 2
อ้างอิงความเห็น


phanuwat3291


พลังงานการช่วยเหลือ
( Level 1 )


คะแนนขอบคุณจากสมาชิก
( 0 )


ตอบกระทู้ ( 5 )
เขียนบทความ ( 0 )

ขอบคุณครับพี่laughing

แสดงความเห็น

อัพโหลดรูปภาพ..คลิก *** เพื่อความปลอดภัยในด้านสิทธิ ไม่อนุญาติให้นำลิ้งรูปภาพจากที่อื่นมาแปะ ถ้าพบเจอ ลบกระทู้ ทันที ***

Back to Top