<html> <head> <title>ThaiCreate.Com Tutorial</title> </head> <body> <form name="form1" method="post" action="PageMultiUploadToMySQL2.php" enctype="multipart/form-data"> <input type="file" name="filUpload[]"><br> <input type="file" name="filUpload[]"><br> <input type="file" name="filUpload[]"><br> <input type="file" name="filUpload[]"><br> <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> </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."]"); ?> <table width="200" border="1"> <tr> <th width="50"> <div align="center">Files ID </div></th> <th width="150"> <div align="center">Files Name </div></th> </tr> <?php while($objResult = mysql_fetch_array($objQuery)) { ?> <tr> <td><div align="center"><?php echo $objResult["FilesID"];?></div></td> <td><center><a href="myfile/<?php echo $objResult["FilesName"];?>"><?php echo $objResult["FilesName"];?></a></center></td> </tr> <?php } ?> </table> <?php mysql_close($objConnect); ?> </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท