|
 |
|
รบกวนสอบถามเรื่อง อัพโหลดไฟล์ ลงฐานข้อมูล แต่ไฟล์ไม่มีในโฟลเดอร์ค่ะ |
|
 |
|
|
 |
 |
|
รบกวนสอบถามหน่อยนะคะ ในฐานข้อมูลเข้าปกติ
ส่วนในโฟลเดอร์ เข้าเพียงแค่ 1 ไฟล์ คือไฟล์ filUpload1 ค่ะ
อยากทราบว่าทำยังไงให้ไฟล์สามารถจัดเก็บลงโฟล์เดอร์ได้ทั้งหมดคะ ?
Code (PHP)
<table width="75%" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<th height="33" colspan="2" align="left" scope="col">อัพโหลดเอกสาร</th>
</tr>
<tr>
<th height="41" scope="col">เอกสารคำขอ</th>
<th scope="col"><input type="file" name="fileUpload[]" id="fileUpload[]"></th>
</tr>
<tr>
<th height="41" scope="col">เอกสารแก้ไขครั้งที่ 1</th>
<th scope="col"><input type="file" name="fileUpload[]" id="fileUpload[]"></th>
</tr>
<tr>
<th height="41" scope="col">เอกสารแก้ไขครั้งที่ 2</th>
<th scope="col"><input type="file" name="fileUpload[]" id="fileUpload[]"></th>
</tr>
<tr>
<th height="41" scope="col">เอกสารแก้ไขครั้งที่ 3</th>
<th scope="col"><input type="file" name="fileUpload[]" id="fileUpload[]"></th>
</tr>
<tr>
<th height="41" scope="col">หนังสือสำคัญ : </th>
<th scope="col"><input type="file" name="fileUpload[]" id="fileUpload[]"></th>
</tr>
</table>
Code (PHP)
<?php
mysql_connect("XXXX","XXX","XXX") or die (mysql_error());
mysql_select_db("asu_project");
mysql_query("SET character_set_results=utf8");
mysql_query("SET character_set_client=utf8");
mysql_query("SET character_set_connection=utf8");
for($i=1;$i<=(int)($_POST["hdnLine"]);$i++)
{
if($_FILES["fileUpload"]["name"][$i] != "")
{
if(move_uploaded_file($_FILES["fileUpload"]["tmp_name"][$i],"myfile/".$_FILES["fileUpload"]["name"][$i]))
{
//*** Insert Record ***//
$strSQL = "INSERT INTO tlo ";
$strSQL .="(tlo_id,tlo_noreq,tlo_date_req,tlo_date,fac_name,tlo_namereq,tlo_claims,tlo_detail,tlo_name,tlo_inventor,type_name,tlo_conclu,date_status,status_name,filUpload,filUpload1,filUpload2,filUpload3,filUpload4) VALUES ('".$_POST["tlo_id"]."',
'".$_POST["tlo_noreq"]."',
'".$_POST["tlo_date_req"]."',
'".$_POST["tlo_date"]."',
'".$_POST[" fac_name"]."',
'".$_POST["tlo_namereq"]."',
'".$_POST["tlo_claims"]."',
'".$_POST["tlo_detail"]."',
'".$_POST["tlo_name"]."',
'".$_POST["tlo_inventor"]."',
'".$_POST["type_name"]."',
'".$_POST["tlo_conclu"]."',
'".$_POST["date_status"]."',
'".$_POST["status_name"]."','".$_FILES["fileUpload"]["name"][0]."','".$_FILES["fileUpload"]["name"][1]."','".$_FILES["fileUpload"]["name"][2]."','".$_FILES["fileUpload"]["name"][3]."','".$_FILES["fileUpload"]["name"][4]."')";
$objQuery = mysql_query($strSQL);
}
}
}
mysql_close();
echo "Copy/Upload Complete<br>";
?>
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2019-02-26 09:35:08 |
By :
Phuto |
View :
619 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จัดการ เรื่อง save file ให้เสร็จก่อน แล้วค่อย insert ตาราง
คุณเอา insert ตาราง ไปไว้ใน loop มันติด primary key หรือ unique key อะไรหรือเปล่า
และก็ศึกษาเรื่อง sql injection ให้ดี หาวิธีการใหม่ เพื่อป้องกันการ hack ข้อมูล
|
 |
 |
 |
 |
Date :
2019-02-26 10:29:37 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
hdnLine นี่เป็น จำนวน ของ file upload
หรือเป็นจำนวนของ record
|
 |
 |
 |
 |
Date :
2019-02-26 11:42:37 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|