douxie5930 2017-05-03 12:54
浏览 61
已采纳

如何上传zip文件并在PHP中显示?

How can I upload a zip file, display the total size of the file, total number of files in the zip file, and display each file name in php code?

<?php
  if ($_FILES) {
      $fileName = $_FILES['zip']['tmp_name'];
        $zip   = zip_open($fileName);
          if ($zip) {
             while ($zip_entry= $zip_read($zip)) {
               echo "<p>";
               echo "<h3> Name:". zip_entry_name($zip_entry). "<h3>";
                  if (zip_entry_open($zip, $zip_entry)) {
                    echo "<h4>File Contents: </h4> ";
                     $contents = zip_entry_read($zip_entry);
                echo $contents;
                echo "<br /><br/>";
                zip_entry_close($zip_entry);
                  }
             }
              zip_close($zip);
           } 

  }
?>
<form method='post' action='' enctype='multipart/form-data'>
 <input type='file' name='zip'><br/>
 <input type='submit' name='upload' value='upload' />
</form>
  • 写回答

2条回答 默认 最新

  • dscc90150010 2017-05-03 13:12
    关注

    you can check file size and contain using verious inbuilt php methods . read from here

    Also can check below issue in your code

    remove $ from while($zip_entry= $zip_read($zip)) {

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大