note 118490 added to ziparchive.open

From: Date: Mon, 14 Dec 2015 22:29:04 +0000
Subject: note 118490 added to ziparchive.open
Groups: php.notes 
Request: Send a blank email to php-notes+get-204355@lists.php.net to get a copy of this message
ZipArchive::OVERWRITE does NOT mean an existing file would be deleted when ZipArchive::open() is called. In fact, the existing file will be deleted before PHP saves the zip archive on disk. PHP takes these steps to finish zipping: 1. When ZipArchive::open('xx.zip') is called If 'xx.zip' exists and is a zip archive, it will be opened and read as a temporary zip file, If the file does not exist, and ZipArchive::CREATE is applied, php will create a temporary empty zip file In these cases, ZipArchive::open() returns true, otherwise it returns an integer error code. 2. Adds file(s) to the temporary zip file when methods such as addFile(), addFromString() are called. 3. Deletes the existing file before saving the temporary zip file on disk. 4. Save the temporary zip file on disk 5. Closes the active archive when ZipArchive::close() is called or at the end of the script Since PHP does NOT delete the existing file before saving the zip archive on disk, you should use unset() to delete it if you want to zip that file's containing folder and save the zip archive in that folder, otherwise you will get a larger and larger zip archive everytime you refresh the page. ---- Server IP: 72.52.91.14 Probable Submitter: 118.117.60.111 ---- Manual Page -- http://php.net/manual/en/ziparchive.open.php Edit -- https://master.php.net/note/edit/118490 Del: integrated -- https://master.php.net/note/delete/118490/integrated Del: useless -- https://master.php.net/note/delete/118490/useless Del: bad code -- https://master.php.net/note/delete/118490/bad+code Del: spam -- https://master.php.net/note/delete/118490/spam Del: non-english -- https://master.php.net/note/delete/118490/non-english Del: in docs -- https://master.php.net/note/delete/118490/in+docs Del: other reasons-- https://master.php.net/note/delete/118490 Reject -- https://master.php.net/note/reject/118490 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#204355) next »