使用PHP解压缩Zip存档 [英] Unzip The Zip Archive With PHP

查看:103
本文介绍了使用PHP解压缩Zip存档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用PHP解压缩zip文件时遇到问题
我在网络上尝试了许多共享脚本 但仍然不起作用
我尝试的最后一个脚本是以下脚本:

I Have A Problem About extract the zip file with PHP
I try many shared script on the web but it still doesn't work
the last script i try is this script :

<?php
$zip = new ZipArchive;
$res = $zip->open('data.zip');
if ($res === TRUE) {
  $zip->extractTo('/extract/');
  $zip->close();
  echo 'woot!';
} else {
  echo 'doh!';
}
?>

运行脚本时,我总是遇到else条件, 我尝试替换data.zip/extract/路径以完成路径http://localhost/basedata/data.ziphttp://localhost/basedata/extract/,但是我仍然遇到else条件,有人可以帮助我吗?

I am always get the else condition when the script is run , I've tried replacing the data.zip and the /extract/ path to complete path http://localhost/basedata/data.zip and http://localhost/basedata/extract/ but I still got the else condition , Anyone can help me?

这是我的整个脚本和zip文件 http://www.mediafire.com/?c49c3xdxjlm58ey

Here Is My whole script and the zip file http://www.mediafire.com/?c49c3xdxjlm58ey

推荐答案

您应该检查打开了哪个错误代码(

You should check which error code gives open (http://www.php.net/manual/en/ziparchive.open.php), that will give you some help.

错误代码如下:

    ZIPARCHIVE::ER_EXISTS -10
    ZIPARCHIVE::ER_INCONS - 21
    ZIPARCHIVE::ER_INVAL - 18
    ZIPARCHIVE::ER_MEMORY - 14
    ZIPARCHIVE::ER_NOENT - 9
    ZIPARCHIVE::ER_NOZIP - 19
    ZIPARCHIVE::ER_OPEN - 11
    ZIPARCHIVE::ER_READ - 5
    ZIPARCHIVE::ER_SEEK - 4

这篇关于使用PHP解压缩Zip存档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆