PHP动态多文件上传的具体代码分享

原创
2016-06-13 11:06:00 634浏览

大家在通过对上传文件代码:

  1. nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. html xmlns="http://www.w3.org/1999/xhtml">
  3. head>
  4. meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  5. title>文档上传title>
  6. head>
  7. body>
  8. mce:script language="javascript">
  9. function AddRow()
  10. {
  11. var eNewRow = tblData.insertRow();
  12. for (var i=0;i1;i++)
  13. {
  14. var eNewCell = eNewRow.insertCell();
  15. eNewCell.innerHTML = "";
  16. }
  17. }
  18. // -->mce:script>
  19. form name="myform" method="post" action="uploadfile.php" enctype="multipart/form-data" >
  20. table id="tblData" width="400" border="0">
  21. input name="postadd" type="hidden" value="php echo "http://".$_SERVER['HTTP_HOST'].$_SERVER["PHP_SELF"]; ?>" />
  22. tr>td>文件上传列表
  23. input type="button" name="addfile" onclick="AddRow()" value="添加列表" />td>tr>
  24. tr>td>input type="file" name="filelist[]" size="50" />td>tr>
  25. table>
  26. input type="submit" name="submitfile" value="提交文件" />
  27. form>
  28. body>
  29. html>

PHP动态多文件上传之提交文件代码:

  1. nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
    >
  2. html xmlns="http://www.w3.org/1999/xhtml">
  3. head>
  4. meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  5. title>文件上传结果title>
  6. head>
  7. body>
  8. php
  9. if ($_POST["submitfile"]!="")
  10. {
  11. $Path="./".date('Ym')."//m.sbmmt.com/m/";
  12. if (!is_dir($Path))//创建路径
  13. { mkdir($Path); }
  14. echo "div>";
  15. for ($i=0;$icount($filelist);$i++)
  16. { //$_FILES["filelist"]["size"][$i]的排列顺序不可以变,
    因为fileist是一个二维数组
  17. if ($_FILES["filelist"]["size"][$i]!=0)
  18. {
  19. $File=$Path.date('Ymdhm')."_".$_FILES["filelist"]["name"][$i];
  20. if (move_uploaded_file($_FILES["filelist"]["tmp_name"][$i],$File))
  21. { echo "文件上传成功 文件类型:".$_FILES["filelist"]
    ["type"][$i]." "."文件名:"
  22. .$_FILES["filelist"]["name"][$i]."br>"; }
  23. else
  24. { echo "文件名:".$_FILES["filelist"]["name"][$i]."上传失败br>"; }
  25. }
  26. }
  27. echo "div>br>a href="$postadd" mce_href="$postadd">返回a>div>";
  28. }
  29. ?>
  30. body>
  31. html>

以上就是PHP动态多文件上传的所有代码。


声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。