Unlink deleting more than just the files passed to it.
- by RMcLeod
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);
}