|
|
|
ส่ง argument ผ่าน javascript ใน innerHTML มีรูปแบบยังไงครับพี่ๆ |
|
|
|
|
|
|
|
id มันเป็น array ไม่ได้ครับ id จะต้องไม่ซ้ำกันครับ ตัวอย่างการใส่ id ให้ element ครับ
Code (php_multiple_upload1.php)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<script language="javascript">
function fncCreateElement(){
var mySpan = document.getElementById('mySpan');
var myLine = document.getElementById('hdnLine');
myLine.value++;
var myElement1 = document.createElement('input');
myElement1.setAttribute('type',"file");
myElement1.setAttribute('name',"fileUpload[]");
myElement1.setAttribute('id',"fil"+myLine.value);
mySpan.appendChild(myElement1);
// Create <br>
var myElement2 = document.createElement('<br>');
myElement2.setAttribute('id',"br"+myLine.value);
mySpan.appendChild(myElement2);
}
function fncDeleteElement(){
var mySpan = document.getElementById('mySpan');
var myLine = document.getElementById('hdnLine');
if(myLine.value > 1 )
{
// Remove input file
var deleteEle = document.getElementById("fil"+myLine.value);
mySpan.removeChild(deleteEle);
// Remove <br>
var deleteBr = document.getElementById("br"+myLine.value);
mySpan.removeChild(deleteBr);
myLine.value--;
}
}
</script>
<body>
<form action="php_multiple_upload2.php" method="post" name="form1" enctype="multipart/form-data">
<input type="file" name="fileUpload[]">
<input name="btnCreate" type="button" value="+" onClick="JavaScript:fncCreateElement();">
<input name="btnDelete" type="button" value="-" onClick="JavaScript:fncDeleteElement();"><br>
<span id="mySpan"></span>
<input id="hdnLine" name="hdnLine" type="hidden" value="1">
<input name="btnSubmit" type="submit" value="Submit">
</form>
</body>
</html>
Code (php_multiple_upload2.php)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<?
for($i=0;$i<count($_FILES["fileUpload"]["name"]);$i++)
{
if($_FILES["fileUpload"]["name"][$i] != "")
{
if(copy($_FILES["fileUpload"]["tmp_name"][$i],"ThaiCreate/".$_FILES["fileUpload"]["name"][$i]))
{
echo "Copy/Upload ".$_FILES["fileUpload"]["name"][$i]." completed.<br>";
}
}
}
?>
</body>
</html>
|
|
|
|
|
Date :
2010-05-21 08:14:16 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|