zip - php ZipArchive addfile not work -


here's code

<?php error_reporting(-1); ini_set('memory_limit','1g');  $zip = new ziparchive(); if ($zip->open(__dir__.'/xxx.zip') === true) {         echo __dir__.'/cpinfo.txt'."\n";         $zip->addfile(__dir__.'/cpinfo.txt', 'newname.txt');                 $x =  $zip->close();         var_dump($x);         echo 'ok'; } else {         echo 'failed'; } ?> 

i have run command

[root@localhost]# php test.php  

and output is

/data/yyy/cpinfo.txt bool(true) ok 

no errors given while adding txt .zip. when open xxx.zip, nothing changed. file xxx.zip contains more 1000 files , 100 folders

when remove 900 files xxx.zip , run script again, it's work.

what doing wrong?

file open limit

ulimit -a 

output

core file size          (blocks, -c) 0 data seg size           (kbytes, -d) unlimited scheduling priority             (-e) 0 file size               (blocks, -f) unlimited pending signals                 (-i) 514831 max locked memory       (kbytes, -l) 64 max memory size         (kbytes, -m) unlimited open files                      (-n) 99999 pipe size            (512 bytes, -p) 8 posix message queues     (bytes, -q) 819200 real-time priority              (-r) 0 stack size              (kbytes, -s) 10240 cpu time               (seconds, -t) unlimited max user processes              (-u) 500000 virtual memory          (kbytes, -v) unlimited file locks                      (-x) unlimited 

php version

php 5.5.13 (cli) (built: jun  3 2014 13:27:36)  copyright (c) 1997-2014 php group zend engine v2.5.0, copyright (c) 1998-2014 zend technologies 

i have tried below code works fine.

code:-

<?php  //after zip files stored in folder $file= "/data/yyy/xxx.zip";  $zip = new ziparchive; echo "zip started.\n";  if ($zip->open($file, ziparchive::create) === true) {         $zip->addfile("/data/yyy/cpinfo.txt");         }     $zip->close();     echo 'done'; ?> 

i have tried 1 file add zip in xxx.zip file "cpinfo.txt", it's added successfully.

hope help


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -