php 動(dòng)態(tài)多文件上傳
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"><!--
動(dòng)態(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" -->
<!-- 將本頁(yè)的網(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[]必須是一個(gè)數(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"><!--
動(dòng)態(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" -->
<!-- 將本頁(yè)的網(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[]必須是一個(gè)數(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]的排列順序不可以變,因?yàn)閒ileist是一個(gè)二維數(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>
- PHP 圖片文件上傳實(shí)現(xiàn)代碼
- 一個(gè)經(jīng)典的PHP文件上傳類分享
- php+ajax實(shí)現(xiàn)圖片文件上傳功能實(shí)例
- PHP實(shí)現(xiàn)視頻文件上傳完整實(shí)例
- php 文件上傳后綴名與文件類型對(duì)照表(幾乎涵蓋所有文件)
- 配置php.ini實(shí)現(xiàn)PHP文件上傳功能
- php+jQuery.uploadify實(shí)現(xiàn)文件上傳教程
- PHP實(shí)現(xiàn)文件上傳功能實(shí)例代碼
- Thinkphp多文件上傳實(shí)現(xiàn)方法
- php文件上傳原理與實(shí)現(xiàn)方法詳解
相關(guān)文章
Yii2.0小部件GridView(兩表聯(lián)查/搜索/分頁(yè))功能的實(shí)現(xiàn)代碼
這篇文章主要介紹了Yii2.0小部件GridView(兩表聯(lián)查/搜索/分頁(yè))功能的實(shí)現(xiàn)代碼,需要的朋友可以參考下2017-08-08win7 wamp 64位 php環(huán)境開(kāi)啟curl服務(wù)遇到的問(wèn)題及解決方法
這篇文章主要介紹了PHP簡(jiǎn)單開(kāi)啟curl的方法,較為詳細(xì)的講述了PHP開(kāi)啟curl函數(shù)庫(kù)的具體步驟與相關(guān)注意事項(xiàng),需要的朋友可以參考下2018-09-09Yii2 中實(shí)現(xiàn)單點(diǎn)登錄的方法
這篇文章主要介紹了Yii2 中實(shí)現(xiàn)單點(diǎn)登錄的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-03-03php使用workman框架實(shí)現(xiàn)socket服務(wù)以及連接客戶端
這篇文章主要介紹了php使用workman框架實(shí)現(xiàn)socket服務(wù)以及連接客戶端,本文列舉了詳細(xì)的過(guò)程和代碼展示,能夠幫助你學(xué)習(xí),需要的朋友可以參考下2021-06-06詳解PHP文件的自動(dòng)加載(autoloading)
這篇文章主要介紹了詳解PHP文件的自動(dòng)加載(autoloading)相關(guān)知識(shí)點(diǎn)以及詳細(xì)用法,有這方面需要的朋友參考下吧。2018-02-02Laravel重定向,a鏈接跳轉(zhuǎn),控制器跳轉(zhuǎn)示例
今天小編就為大家分享一篇Laravel重定向,a鏈接跳轉(zhuǎn),控制器跳轉(zhuǎn)示例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-10-10Yii2實(shí)現(xiàn)log輸出到file及database的方法
這篇文章主要介紹了Yii2實(shí)現(xiàn)log輸出到file及database的方法,結(jié)合實(shí)例形式分析了Yii2日志輸出到文件及數(shù)據(jù)庫(kù)的相關(guān)設(shè)置與實(shí)現(xiàn)技巧,需要的朋友可以參考下2016-11-11PHP實(shí)現(xiàn)QQ登錄的開(kāi)原理和實(shí)現(xiàn)過(guò)程
本文主要給大家講述了PHP實(shí)現(xiàn)QQ登錄的開(kāi)原理以及相關(guān)的代碼實(shí)現(xiàn)過(guò)程,對(duì)此有興趣和需要的朋友參考下吧。2018-02-02