Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Update: After some discussion in chat we found out, that <code>$_SESSION['images']</code> contains <code>http://</code> urls but <code>ZipArchive</code> itself does not support adding files from remote sources. If you want to add remote images you'll have to download them before. So we've changed the <code>addFile()</code> related part to:</p> <pre><code>//add the files foreach($images as $file) { $tmpname = tempnam(sys_get_temp_dir(), 'test'); file_put_contents($tmpname, file_get_contents($file)); $zip-&gt;addFile($tmpname, basename($file)); unlink($tmpname); } </code></pre> <hr> <p>Also there is is a logic error, or better, a typo. Replace </p> <pre><code>$zzz = $zip-&gt;open($destination, ZipArchive::CREATE); if($zzz !== true) { echo "created archive&lt;br /&gt;"; } ... </code></pre> <p>by </p> <pre><code>$zzz = $zip-&gt;open($destination, ZipArchive::CREATE); if($zzz === true) { echo "created archive&lt;br /&gt;"; } ... </code></pre> <hr> <p>Further note, that the zip is created in memory and will be written to disk not until calling <a href="http://de1.php.net/manual/en/ziparchive.close.php" rel="nofollow"><code>ZipArchive::close()</code></a>. Check the first comment on the manual page:</p> <blockquote> <p>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.</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload