|
 |
|
ขอรบกวนอีกแบบครับ วิธีการ import multiple txtfile : รับค่าผ่าน form data textfile แบบ Dinamic แล้ว Insert ลง mysql database |
|
 |
|
|
 |
 |
|
index.php
Code (PHP)
<form name="form1" method="post" action="multipleimp.php" enctype="multipart/form-data">
<input type="file" name="filUpload[]"><br>
<input type="file" name="filUpload[]"><br>
<input type="file" name="filUpload[]"><br>
<input name="btnSubmit" type="submit" value="Submit">
</form>
multipleimp.php
Code (PHP)
<?php
for($i=0;$i<count($_FILES["filUpload"]["name"]);$i++)
{
if($_FILES["filUpload"]["name"][$i] != "")
{
$tmpfile=$_FILES["filUpload"]["tmp_name"][$i];
echo $tmpfile."<br>";
echo $_FILES["filUpload"]["name"][$i];
$file=@fopen($tmpfile,"r") or die("Can Not Open File. Please contact admin!");
while (!feof($file)) {
$buffer = fgets($file, 4096);
$text= explode(";",$buffer);
$arr_num = count($text);
echo"$text[0] $text[1] $text[2] $text[3] $text[4] $text[5] $text[6] $text[7] <br>";
//คำสั่ง Insert
}
}
}
?>
ผมลองเดา ประยุกต์จากการอัพโหลดไฟล์ พอได้ tmp_name มา แล้วให้มาอ่านค่าในไฟล์ tmp แบบนี้พอได้มั้ย แต่ไม่เป็นภาษาไทย วิธีที่ถูกต้องกว่านี้มั้ยครับ
|
ประวัติการแก้ไข 2020-07-17 02:46:23 2020-07-17 02:52:46 2020-07-17 02:56:25
 |
 |
 |
 |
Date :
2020-07-17 02:45:30 |
By :
1887917004854085 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณสำหรับการแบ่งปันครับ 
การทำส้มตำ ไม่มีสูตรตายตัว ผมชอบใส่ปลาร้า แต่ไม่ชอบฉีกเนื้อปลาร้า (เค็ม...)
|
 |
 |
 |
 |
Date :
2020-07-17 19:28:31 |
By :
PhrayaDev |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|