<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
	date_default_timezone_set('Asia/Bangkok');
	$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
	$objDB = mysql_select_db("afm_ass");
	$idofimg = $_POST["gadgetid"];
	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 gallery ";
				$strSQL .="(Gadget_id,GalleryShot) VALUES ('".$idofimg."','".$_FILES["filUpload"]["name"][$i]."')";
				$objQuery = mysql_query($strSQL);
			}
		}
	}

									echo"<script language='JavaScript'>";
									echo"alert('บันทึกรูปภาพเรียบร้อย');";
									echo"</script>";		
									echo "<meta http-equiv='refresh' content='0;url=viewgadget.php?view_id=$idofimg' />";
?>
</body>
</html>