lyl615 2018-10-16 01:13 采纳率: 33.3%
浏览 2347
已采纳

html多文件上传只有一个文件被上传

按ctrl同时选中多个文件同时上传,结果只有最后一个被选中的文件被上传,请问什么原因
图片说明
图片说明
图片说明
图片说明

  • 写回答

4条回答 默认 最新

  • Go 旅城通票 2018-10-16 01:51
    关注

    名字改为数组形式

     <form action="" method="post" enctype="multipart/form-data">
      Send these files:<br />
      <input name="upload[]" type="file" multiple /><br />
      <input type="submit" value="Send files" />
    </form>
    <?php
    print_r($_FILES["upload"]);
      ?>
    

    保存文件

    
    // Count # of uploaded files in array
    $total = count($_FILES['upload']['name']);
    
    // Loop through each file
    for($i=0; $i<$total; $i++) {
      //Get the temp file path
      $tmpFilePath = $_FILES['upload']['tmp_name'][$i];
    
      //Make sure we have a filepath
      if ($tmpFilePath != ""){
        //Setup our new file path
        $newFilePath = "./uploadFiles/" . $_FILES['upload']['name'][$i];
    
        //Upload the file into the temp dir
        if(move_uploaded_file($tmpFilePath, $newFilePath)) {
    
          //Handle other code here
    
        }
      }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64