简体   繁体   English

PHP7中的ZipArchive找不到zip的内容

[英]ZipArchive in PHP7 cannot find content of zip

I have a PHP script to unzip a zip file from a form, but whatever content i put in the zip, the opened zip cannot find the items. 我有一个PHP脚本可以从表单中解压缩zip文件,但是无论我放入zip的内容如何,​​打开的zip都找不到项目。 When I var_dump() my zip I get this: 当我用var_dump()压缩时,我得到以下信息:

object(ZipArchive)#800 (5) {
    ["status"]=> int(0) ["statusSys"]=> int(0) 
    ["numFiles"]=> int(0) 
    ["filename"]=> string(14) "/tmp/php83KJHe" 
    ["comment"]=> string(0) ""
} 

here is the script: 这是脚本:

$zip     = new  \ZipArchive();
$zipname     = $_FILES[ 'lezip' ][ 'tmp_name' ];
$zip->open( $zipname, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE );
var_dump( $zip );
$zipsuccess = $zip->extractTo( $destination );
var_dump( ' success: ' . $zipsuccess );

the success dump says it is ok 成功转储说没关系

string(11) " success: 1" 

And i did set up the $destination folder, it exists and have write access. 而且我确实设置了$ destination文件夹,该文件夹存在并且具有写访问权。

Why can't ZipArchive find any items to the zips i upload ? 为什么ZipArchive找不到我上传的zip的任何项目?

From PHP docs on ZipArchive::OVERWRITE : 来自ZipArchive::OVERWRITE上的PHP文档

Always start a new archive, this mode will overwrite the file if it already exists. 始终启动一个新的存档,如果文件已经存在,此模式将覆盖该文件。

You can't use this flag if you wish to read an existing archive. 如果您想读取现有存档,则不能使用此标志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM