Unlink deleting more than just the files passed to it.

Posted by RMcLeod on Stack Overflow See other posts from Stack Overflow or by RMcLeod
Published on 2010-04-10T10:01:45Z Indexed on 2010/04/10 10:03 UTC
Read the original article Hit count: 168

Filed under:
|

I'm creating an SQL file, placing this file into a zip file with some images and then deleting the SQL file with unlink.Strange thing is it deletes the zip file as well.

if (file_put_contents($sqlFileName, $sql) !== false) {
        $zip = new ZipArchive;
        if ($zip->open($workingDir . $now . '.zip', ZipArchive::CREATE) === true) {
            $zip->addFile($sqlFileName, basename($sqlFileName));
            if(! empty($images)) {
                foreach ($images as $image) {
                    $zip->addFile($imagesDir . $image, $image);
                }
            }
        }
        unlink($sqlFileName);
}

© Stack Overflow or respective owner

Related posts about php

Related posts about filesystems