note 108193 added to ziparchive.addfile

From: Date: Fri, 06 Apr 2012 00:12:22 +0000
Subject: note 108193 added to ziparchive.addfile
Groups: php.notes 
Request: Send a blank email to php-notes+get-186991@lists.php.net to get a copy of this message
Another surprise, which took a lot of trouble. So that after you add a file to the archive it can be safely removed, took advantage of such construction: if (!is_file ($archive)) : $result = $zip->open ($archive, ZipArchive::CREATE); else : $result = $zip->open ($archive); endif; if ($result === TRUE) : if (($zip->addFile ($file, $filename)) === TRUE) : $theoreticaly_added = TRUE; endif; if ((($zip->close ()) === TRUE) && $theoreticaly_added) : unlink ($file); endif; endif; Now the files will not disappear. But perhaps there is a simpler solution, which gives 100% guarantee? ---- Server IP: 69.147.83.197 Probable Submitter: 31.28.228.9 ---- Manual Page -- http://www.php.net/manual/en/ziparchive.addfile.php Edit -- https://master.php.net/note/edit/108193 Del: integrated -- https://master.php.net/note/delete/108193/integrated Del: useless -- https://master.php.net/note/delete/108193/useless Del: bad code -- https://master.php.net/note/delete/108193/bad+code Del: spam -- https://master.php.net/note/delete/108193/spam Del: non-english -- https://master.php.net/note/delete/108193/non-english Del: in docs -- https://master.php.net/note/delete/108193/in+docs Del: other reasons-- https://master.php.net/note/delete/108193 Reject -- https://master.php.net/note/reject/108193 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#186991) next »