If you have created a zip file and added a file to it without error, yet the ZipArchive::close call fails (with ER_TMPOPEN: "Failure to create temporary file") and the zip file is not created, check to see if your ZipArchive::open call specifies a pathname containing nonexisting directories. If you expect a containing hierarchy of one or more directories, you must create them yourself before using using ZipArchive. You can write a simple function to recurse using dirname to find each parent directory, creating those that don't exist by using mkdir when leaving the recursion.
ZipArchive::close
(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
ZipArchive::close — アクティブな (オープンされた、あるいは新しく作成された) アーカイブを閉じる
説明
bool ZipArchive::close
( void
)
オープンされた、あるいは作成されたアーカイブを閉じ、 変更内容を保存します。このメソッドは、 スクリプトの最後で自動的にコールされます。
パラメータ
この関数にはパラメータはありません。
返り値
成功した場合に TRUE を、失敗した場合に FALSE を返します。
m021 at springtimesoftware dot com
19-May-2011 07:14
webnull dot www at gmail dot com
12-Mar-2011 06:40
Please note you must have write permissions to file and directory where the files is placed to save the archive.
john factorial
29-Dec-2010 05:58
If you're adding multiple files to a zip and your $zip->close() call is returning FALSE, ensure that all the files you added actually exist. Apparently $zip->addFile() returns TRUE even if the file doesn't actually exist. It's a good idea to check each file with file_exists() or is_readable() before calling $zip->addFile() on it.
jared at kippage dot com
02-Sep-2009 12:08
It may seem a little obvious to some but it was an oversight on my behalf.
If you are adding files to the zip file that you want to be deleted make sure you delete AFTER you call the close() function.
If the files added to the object aren't available at save time the zip file will not be created.
gilthans at gmail dot com
22-Oct-2007 05:16
Don't forget to check the zip isn't empty, folks - otherwise the zip won't be created at all, and the server will issue no warning!
I used a certain loop to add files to the zip, and struggled with permissions and documentation for hours before I realize the loop ended up adding no file, even though addFile WAS called, but on a non-existent file.
This might be the reason your zips aren't popping up.
