|
|
|
multiple upload up รูป หลายๆรูปพร้อมกัน เก็บชื่อลง db จะสร้าง ตารางยังงัยครับ |
|
|
|
|
|
|
|
ตารางปกติ ทั่วไปแหละครับ เพียงแต่ตอนที่คุณเอารูปเข้าไปเก็บ ต้องใช้ลูปวนจนกว่าจะเก็บรูปหมดครับ
|
|
|
|
|
Date :
2009-10-07 22:46:29 |
By :
NanoThoro |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<form name="form1" method="post" action="PageMultiFiles2.php" enctype="multipart/form-data">
<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>
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<?
for($i=0;$i<count($_FILES["filUpload"]["name"]);$i++)
{
if($_FILES["filUpload"]["name"][$i] != "")
{
if(copy($_FILES["filUpload"]["tmp_name"][$i],"myfile/".$_FILES["filUpload"]["name"][$i]))
{
echo "Copy/Upload Complete<br>";
}
}
}
?>
</body>
</html>
บทเรียนที่https://www.thaicreate.com/php/php-html-mutil-file-field-upload.html
|
|
|
|
|
Date :
2009-10-07 22:48:40 |
By :
somparn |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไหนว่าจะไปนอนแล้วไงเพ่สมภาณ อิอิอิ กำลังรอน้องต้นอ้ออะดิ ฮาๆๆๆๆ
|
|
|
|
|
Date :
2009-10-07 23:03:11 |
By :
NanoThoro |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
รู้อีก....อิอิอิอิ กำลังอ่านหนังสือ php&ajex อยู่คงจะนอนสักตี 1,2 นั้นแหละบอกให้ add msn มาคุยกันไม่ยอม add
|
|
|
|
|
Date :
2009-10-07 23:10:37 |
By :
somparn |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PageMultiUploadToMySQL1.html)
<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>
Code (PageMultiUploadToMySQL2.php)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<?
$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(copy($_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>
Code (PageMultiUploadToMySQL3.php)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<?
$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/<?=$objResult["FilesName"];?>" target="_blank"><img src="myfile/<?=$objResult["FilesName"];?>" width="100" height="100" border="0"></a></div></td>
</tr>
</table>
<?
echo"</td>";
if(($intRows)%2==0)
{
echo"</tr>";
}
else
{
echo "<td>";
}
}
echo"</tr></table>";
?>
<?
mysql_close($objConnect);
?>
</body>
</html>
|
|
|
|
|
Date :
2009-10-27 06:36:02 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
รูปมาแต่ชื่อรูปไม่ลงใน DB อ่ะ
|
|
|
|
|
Date :
2010-06-09 14:57:33 |
By :
panteen |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|