<html> <head> <title>ThaiCreate.Com Tutorial</title> </head> <body> <form name="form1" method="post" action="PageUploadToMySQL2.php" enctype="multipart/form-data"> <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 if(move_uploaded_file($_FILES["filUpload"]["tmp_name"],"myfile/".$_FILES["filUpload"]["name"])) { echo "Copy/Upload Complete<br>"; //*** Insert Record ***// $objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database"); $objDB = mysql_select_db("mydatabase"); $strSQL = "INSERT INTO files "; $strSQL .="(FilesName) VALUES ('".$_FILES["filUpload"]["name"]."')"; $objQuery = mysql_query($strSQL); } ?> <a href="PageUploadToMySQL3.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 ของทีมงานไทยครีเอท