views:

34

answers:

1

Hi,

I have a problem with the php_zip.dll's ZipArchive class. I'm using it through the ZipArchiveImproved wrapper class suggested on php.net to avoid the max file-handle issue.

The problem is really simple: 700 files are added properly (jpg image files), and the rest fails. The addFile method returns false.

The PHP version is 5.2.6.

The weird thing is that this actually used to work.
What could be the problem? Can you give me any clues?

Thank you very much in advance!

Edit: sorry, it's not true that I'm not getting any error message (display_errors was switched off in php.ini I didn't notice it before). From the 701. file on, I'm getting the following error message:

Warning: ZipArchive::addFile() [ziparchive.addfile]: Invalid or unitialized Zip object in /.../includes/ZipArchiveImproved.class.php on line 104

Looks like the close() call returns false, but issues no error. Any ideas?

Edit 2: the relevant source:

include_once DIR_INCLUDES . 'ZipArchiveImproved.class.php';

ini_set('max_execution_time', 0);

$filePath = $_SESSION['fqm_archivePath'];

$zip = new ZipArchiveImproved();
if(! $zip->open($filePath, ZipArchive::CREATE))
{
    echo '<div class="error">Hiba: a célfájl a(z) "' . $filePath . '" útvonalon nem hozható létre.</div>';
    return;
}

echo('Starting (' . count($_POST['files']) . ' files)...<br>');

$addedDirs = array();
foreach($_POST['files'] as $i => $f)
{
    $d = getUserNameByPicPath($f);
    if(! isset($addedDirs[$d]))
    {
        $addedDirs[$d] = true;
        $zip->addEmptyDir($d);

        echo('Added dir "' . $d . '".<br>');
    }

    $addName = $d . '/' . basename($f);
    $r = $zip->addFile($f, $addName);
    if(! $r)
    {
        echo('<font color="Red">[' . ($i + 1) . '] Failed to add file "' . $f . '" as "' . $addName . '".</font><br>');
    }
}

$a = $zip->addFromString('test.txt', 'Moooo');
if($a)
{
    echo 'Added string successfully.<br>';
}
else
{
    echo 'Failed to add string.<br>';
}

$zip->close();
A: 

The problem is described here: http://www.php.net/manual/en/function.ziparchive-open.php#88765

Have you tried to specify both flags?

FractalizeR
Yes, I've tried it, same result. I have also read through all comments and google search results I could find. Nothing has helped so far. :S
ShdNx