<html> <head> <title>ThaiCreate.Com Tutorial</title> <script language="javascript"> function fncCreateElement(){ var mySpan = document.getElementById('mySpan'); var myElement1 = document.createElement('input'); myElement1.setAttribute('type',"file"); myElement1.setAttribute('name',"filUpload[]"); //myElement1.setAttribute('id',"filUpload[]"); mySpan.appendChild(myElement1); //*** Remove Element ***// /* var deleteEle = document.getElementById('txt1'); mySpan.removeChild(deleteEle); */ var myElement2 = document.createElement('<br>'); mySpan.appendChild(myElement2); } </script> </head> <body> <form name="frmMain" method="post" action="PageMultiUploadToMySQL2.php" enctype="multipart/form-data"> <input type="file" name="filUpload[]"> <input name="btnButton" id="btnButton" type="button" value="+" onClick="JavaScript:fncCreateElement();"> <br> <span id="mySpan"></span> <input name="btnSubmit" type="submit" value="Submit"> </form> </body> </html>
<html> <head> <title>ThaiCreate.Com Tutorial</title> </head> <body> <?php $objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database"); $objDB = mysql_select_db("mydatabase"); for($i=0;$i<count($_FILES["filUpload"]["name"]);$i++) { if($_FILES["filUpload"]["name"][$i] != "") { if(move_uploaded_file($_FILES["filUpload"]["tmp_name"][$i],"myfile/".$_FILES["filUpload"]["name"][$i])) { //*** Insert Record ***// $strSQL = "INSERT INTO files "; $strSQL .="(FilesName) VALUES ('".$_FILES["filUpload"]["name"][$i]."')"; $objQuery = mysql_query($strSQL); } } } echo "Copy/Upload Complete<br>"; ?> <a href="PageMultiUploadToMySQL3.php">View files</a> </body> </html>
<html> <head> <title>ThaiCreate.Com Tutorial</title> </head> <body> <?php $objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database"); $objDB = mysql_select_db("mydatabase"); $strSQL = "SELECT * FROM files"; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); echo"<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\"><tr>"; $intRows = 0; while($objResult = mysql_fetch_array($objQuery)) { $intRows++; echo "<td>"; ?> <table width="91" border="0" cellspacing="0" cellpadding="0"> <tr> <td><div align="center"><a href="myfile/<?php echo $objResult["FilesName"];?>" target="_blank"><img src="myfile/<?php echo $objResult["FilesName"];?>" width="100" height="100" border="0"></a></div></td> </tr> </table> <?php echo"</td>"; if(($intRows)%2==0) { echo"</tr>"; } else { echo "<td>"; } } echo"</tr></table>"; ?> <?php mysql_close($objConnect); ?> </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท