php 動態(tài)多文件上傳
更新時間:2009年01月18日 06:01:56 作者:
php 動態(tài)多文件上傳實例代碼,前臺是javascript后臺用的是php
文件上傳代碼
view plaincopy to clipboardprint?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>文檔上傳</title>
</head>
<body>
<script language="javascript"><!--
動態(tài)添加文件選擇控件-->
function AddRow()
{
var eNewRow = tblData.insertRow();
for (var i=0;i<1;i++)
{
var eNewCell = eNewRow.insertCell();
eNewCell.innerHTML = "<tr><td><input type='file' name='filelist[]' size='50'/></td></tr>";
}
}
// --></script>
<form name="myform" method="post" action="uploadfile.php" enctype="multipart/form-data" >
<table id="tblData" width="400" border="0">
<!-- 將上傳文件必須用post的方法和enctype="multipart/form-data" -->
<!-- 將本頁的網(wǎng)址傳給uploadfile.php-->
<input name="postadd" type="hidden" value="<?php echo "http://".$_SERVER['HTTP_HOST'].$_SERVER["PHP_SELF"]; ?>" />
<tr><td>文件上傳列表
<input type="button" name="addfile" onclick="AddRow()" value="添加列表" /></td></tr>
<!-- filelist[]必須是一個數(shù)組-->
<tr><td><input type="file" name="filelist[]" size="50" /></td></tr>
</table>
<input type="submit" name="submitfile" value="提交文件" />
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>文檔上傳</title>
</head>
<body>
<script language="javascript"><!--
動態(tài)添加文件選擇控件-->
function AddRow()
{
var eNewRow = tblData.insertRow();
for (var i=0;i<1;i++)
{
var eNewCell = eNewRow.insertCell();
eNewCell.innerHTML = "<tr><td><input type='file' name='filelist[]' size='50'/></td></tr>";
}
}
// --></script>
<form name="myform" method="post" action="uploadfile.php" enctype="multipart/form-data" >
<table id="tblData" width="400" border="0">
<!-- 將上傳文件必須用post的方法和enctype="multipart/form-data" -->
<!-- 將本頁的網(wǎng)址傳給uploadfile.php-->
<input name="postadd" type="hidden" value="<?php echo "http://".$_SERVER['HTTP_HOST'].$_SERVER["PHP_SELF"]; ?>" />
<tr><td>文件上傳列表
<input type="button" name="addfile" onclick="AddRow()" value="添加列表" /></td></tr>
<!-- filelist[]必須是一個數(shù)組-->
<tr><td><input type="file" name="filelist[]" size="50" /></td></tr>
</table>
<input type="submit" name="submitfile" value="提交文件" />
</form>
</body>
</html>
提交文件代碼
view plaincopy to clipboardprint?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>文件上傳結(jié)果</title>
</head>
<body>
<?php
if ($_POST["submitfile"]!="")
{
$Path="./".date('Ym')."/";
if (!is_dir($Path))//創(chuàng)建路徑
{ mkdir($Path); }
echo "<div>";
for ($i=0;$i<count($filelist);$i++)
{ //$_FILES["filelist"]["size"][$i]的排列順序不可以變,因為fileist是一個二維數(shù)組
if ($_FILES["filelist"]["size"][$i]!=0)
{
$File=$Path.date('Ymdhm')."_".$_FILES["filelist"]["name"][$i];
if (move_uploaded_file($_FILES["filelist"]["tmp_name"][$i],$File))
{ echo "文件上傳成功 文件類型:".$_FILES["filelist"]["type"][$i]." "."文件名:"
.$_FILES["filelist"]["name"][$i]."<br>"; }
else
{ echo "文件名:".$_FILES["filelist"]["name"][$i]."上傳失敗</br>"; }
}
}
echo "</div><br><a href="$postadd" href="$postadd">返回</a></div>";
}
?>
</body>
</html>
view plaincopy to clipboardprint?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>文檔上傳</title>
</head>
<body>
<script language="javascript"><!--
動態(tài)添加文件選擇控件-->
function AddRow()
{
var eNewRow = tblData.insertRow();
for (var i=0;i<1;i++)
{
var eNewCell = eNewRow.insertCell();
eNewCell.innerHTML = "<tr><td><input type='file' name='filelist[]' size='50'/></td></tr>";
}
}
// --></script>
<form name="myform" method="post" action="uploadfile.php" enctype="multipart/form-data" >
<table id="tblData" width="400" border="0">
<!-- 將上傳文件必須用post的方法和enctype="multipart/form-data" -->
<!-- 將本頁的網(wǎng)址傳給uploadfile.php-->
<input name="postadd" type="hidden" value="<?php echo "http://".$_SERVER['HTTP_HOST'].$_SERVER["PHP_SELF"]; ?>" />
<tr><td>文件上傳列表
<input type="button" name="addfile" onclick="AddRow()" value="添加列表" /></td></tr>
<!-- filelist[]必須是一個數(shù)組-->
<tr><td><input type="file" name="filelist[]" size="50" /></td></tr>
</table>
<input type="submit" name="submitfile" value="提交文件" />
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>文檔上傳</title>
</head>
<body>
<script language="javascript"><!--
動態(tài)添加文件選擇控件-->
function AddRow()
{
var eNewRow = tblData.insertRow();
for (var i=0;i<1;i++)
{
var eNewCell = eNewRow.insertCell();
eNewCell.innerHTML = "<tr><td><input type='file' name='filelist[]' size='50'/></td></tr>";
}
}
// --></script>
<form name="myform" method="post" action="uploadfile.php" enctype="multipart/form-data" >
<table id="tblData" width="400" border="0">
<!-- 將上傳文件必須用post的方法和enctype="multipart/form-data" -->
<!-- 將本頁的網(wǎng)址傳給uploadfile.php-->
<input name="postadd" type="hidden" value="<?php echo "http://".$_SERVER['HTTP_HOST'].$_SERVER["PHP_SELF"]; ?>" />
<tr><td>文件上傳列表
<input type="button" name="addfile" onclick="AddRow()" value="添加列表" /></td></tr>
<!-- filelist[]必須是一個數(shù)組-->
<tr><td><input type="file" name="filelist[]" size="50" /></td></tr>
</table>
<input type="submit" name="submitfile" value="提交文件" />
</form>
</body>
</html>
提交文件代碼
view plaincopy to clipboardprint?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>文件上傳結(jié)果</title>
</head>
<body>
<?php
if ($_POST["submitfile"]!="")
{
$Path="./".date('Ym')."/";
if (!is_dir($Path))//創(chuàng)建路徑
{ mkdir($Path); }
echo "<div>";
for ($i=0;$i<count($filelist);$i++)
{ //$_FILES["filelist"]["size"][$i]的排列順序不可以變,因為fileist是一個二維數(shù)組
if ($_FILES["filelist"]["size"][$i]!=0)
{
$File=$Path.date('Ymdhm')."_".$_FILES["filelist"]["name"][$i];
if (move_uploaded_file($_FILES["filelist"]["tmp_name"][$i],$File))
{ echo "文件上傳成功 文件類型:".$_FILES["filelist"]["type"][$i]." "."文件名:"
.$_FILES["filelist"]["name"][$i]."<br>"; }
else
{ echo "文件名:".$_FILES["filelist"]["name"][$i]."上傳失敗</br>"; }
}
}
echo "</div><br><a href="$postadd" href="$postadd">返回</a></div>";
}
?>
</body>
</html>
相關(guān)文章
FleaPHP框架數(shù)據(jù)庫查詢條件($conditions)寫法總結(jié)
這篇文章主要介紹了FleaPHP框架數(shù)據(jù)庫查詢條件($conditions)寫法,結(jié)合實例形式總結(jié)分析了針對$conditions參數(shù)為整數(shù),字符串,數(shù)組等情況的使用方法及各種查詢技巧,需要的朋友可以參考下2016-03-03
php 廣告點(diǎn)擊統(tǒng)計代碼(php+mysql)
本文講的是php 廣告點(diǎn)擊統(tǒng)計代碼, php 廣告點(diǎn)擊統(tǒng)計代碼,昨天晚上有幾個IDC網(wǎng)想與本站合作放些廣告,但是我想看看廣告效果后想了就寫了一個簡單的廣告統(tǒng)計代碼了,這里只是等的統(tǒng)計不能IP限制或是惡心點(diǎn)擊等等了2018-02-02
關(guān)于laravel-admin ueditor 集成并解決刷新的問題
今天小編就為大家分享一篇關(guān)于laravel-admin ueditor 集成并解決刷新的問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-10-10
LaravelS通過Swoole加速Laravel/Lumen詳解
這篇文章主要給大家介紹了關(guān)于LaravelS通過Swoole加速Laravel/Lumen的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。2018-03-03
關(guān)于php微信訂閱號開發(fā)之token驗證后自動發(fā)送消息給訂閱號但是沒有消息返回的問題
最近做了個項目,當(dāng)token驗證之后,發(fā)送消息給訂閱號,但是沒有消息返回,下面小編通過本篇文章給大家分享我的解決辦法2015-12-12

