当前位置:Gxlcms > PHP教程 > phpjquery多文件上传_PHP教程

phpjquery多文件上传_PHP教程

时间:2021-07-01 10:21:17 帮助过:1人阅读

php jquery 多文件上传

php jquery 多文件上传演示

XML/HTML Code
  1. Upload
  2. upload.php

    PHP Code
    1. //If directory doesnot exists create it.
    2. $output_dir = "../upload";
    3. if(isset($_FILES["myfile"]))
    4. {
    5. $ret = array();
    6. $error =$_FILES["myfile"]["error"];
    7. {
    8. if(!is_array($_FILES["myfile"]['name'])) //single file
    9. {
    10. $fileName = $_FILES["myfile"]["name"];
    11. move_uploaded_file($_FILES["myfile"]["tmp_name"],$output_dir. $_FILES["myfile"]["name"]);
    12. //echo "
      Error: ".$_FILES["myfile"]["error"];
    13. $ret[$fileName]= $output_dir.$fileName;
    14. }
    15. else
    16. {
    17. $fileCount = count($_FILES["myfile"]['name']);
    18. for($i=0; $i < $fileCount; $i++)
    19. {
    20. $fileName = $_FILES["myfile"]["name"][$i];
    21. $ret[$fileName]= $output_dir.$fileName;
    22. move_uploaded_file($_FILES["myfile"]["tmp_name"][$i],$output_dir.$fileName );
    23. }
    24. }
    25. }
    26. echo json_encode($ret);
    27. }
    28. ?>


      原文地址:http://www.freejs.net/article_biaodan_116.html

      www.bkjia.comtruehttp://www.bkjia.com/PHPjc/621610.htmlTechArticlephp jquery 多文件上传 演示 XML/HTML Code Upload script $(document).ready(function() { var settings = { url: "upload.php", method: "POST", allowedTypes:"jpg,png,gif,doc,pdf,z...

人气教程排行