欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php jquery 多文件上传_PHP教程

程序员文章站 2024-02-05 14:20:10
...

php jquery 多文件上传

php jquery 多文件上传_PHP教程演示

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 {
    19. $fileName = $_FILES["myfile"]["name"][$i];
    20. $ret[$fileName]= $output_dir.$fileName;
    21. move_uploaded_file($_FILES["myfile"]["tmp_name"][$i],$output_dir.$fileName );
    22. }
    23. }
    24. }
    25. echo json_encode($ret);
    26. }
    27. ?>


      原文地址: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...
相关标签: php jquery