Warning: ZipArchive::close(): Failure to create temporary file: Permission denied in

Warning: ZipArchive::close(): Failure to create temporary file: Permission denied in

Fatal error: Uncaught PHPExcel_Writer_Exception: Could not close zip file

The most common cause of this error when saving to php://output is an open_basedir restriction that doesn’t include a valid system’s temp folder (e.g. /tmp), or permissions for the system’s temp folder…  can also affect this, even when the obvious permissions appear to be set correctly.

A possible workround is to write the file to the filesystem in a directory that you know you do have full privileges to write, and then use readfile() to stream that file to php://output before deleting the file

Comments

One response to “Warning: ZipArchive::close(): Failure to create temporary file: Permission denied in”

  1. Joy1647 Avatar
    Joy1647

    Nice article.

Leave a Reply to Joy1647 Cancel reply

Your email address will not be published. Required fields are marked *