<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:series="http://unfoldingneurons.com/"
> <channel><title>Comments on: Create a Zip File Using&#160;PHP</title> <atom:link href="http://davidwalsh.name/create-zip-php/feed" rel="self" type="application/rss+xml" /><link>http://davidwalsh.name/create-zip-php</link> <description>Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</description> <lastBuildDate>Tue, 22 May 2012 05:31:04 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>By: Surya</title><link>http://davidwalsh.name/create-zip-php#comment-32269</link> <dc:creator>Surya</dc:creator> <pubDate>Sun, 20 May 2012 17:25:10 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2345#comment-32269</guid> <description>It does not work for meopen($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {
return false;
}
//add the files
foreach($valid_files as $file) {
$zip-&gt;addFile($file,$file);
}
//debug
//echo &#039;The zip archive contains &#039;,$zip-&gt;numFiles,&#039; files with a status of &#039;,$zip-&gt;status;
//close the zip -- done!
$zip-&gt;close();
//check to make sure the file exists
return file_exists($destination);
}
else
{
return false;
}
}$files_to_zip = array();
//getting the relative path along with the file through POST from a HTML form
foreach($_POST[&#039;song&#039;] as $fileabc)
{
$files_to_zip[]=$fileabc;
}
//if true, good; if false, zip creation failed
$result = create_zip($files_to_zip,&#039;my-archive.zip&#039;);
if($result==true)echo &quot;Success&quot;; else echo &quot;failed&quot;;
?&gt;</description> <content:encoded><![CDATA[<p>It does not work for me</p><p>open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {<br
/> return false;<br
/> }<br
/> //add the files<br
/> foreach($valid_files as $file) {<br
/> $zip-&gt;addFile($file,$file);<br
/> }<br
/> //debug<br
/> //echo &#8216;The zip archive contains &#8216;,$zip-&gt;numFiles,&#8217; files with a status of &#8216;,$zip-&gt;status;</p><p> //close the zip &#8212; done!<br
/> $zip-&gt;close();</p><p> //check to make sure the file exists<br
/> return file_exists($destination);<br
/> }<br
/> else<br
/> {<br
/> return false;<br
/> }<br
/> }</p><p>$files_to_zip = array();<br
/> //getting the relative path along with the file through POST from a HTML form<br
/> foreach($_POST['song'] as $fileabc)<br
/> {<br
/> $files_to_zip[]=$fileabc;<br
/> }<br
/> //if true, good; if false, zip creation failed<br
/> $result = create_zip($files_to_zip,&#8217;my-archive.zip&#8217;);<br
/> if($result==true)echo &#8220;Success&#8221;; else echo &#8220;failed&#8221;;<br
/> ?&gt;</p> ]]></content:encoded> </item> <item><title>By: Drew Wesley</title><link>http://davidwalsh.name/create-zip-php#comment-31769</link> <dc:creator>Drew Wesley</dc:creator> <pubDate>Thu, 19 Apr 2012 23:15:55 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2345#comment-31769</guid> <description>Can the destination parameter be cached in memory or in a temporary directory instead of an actual location? If not, unlink() is cool - I&#039;m just trying to avoid having to write to disk for a download.</description> <content:encoded><![CDATA[<p>Can the destination parameter be cached in memory or in a temporary directory instead of an actual location? If not, unlink() is cool &#8211; I&#8217;m just trying to avoid having to write to disk for a download.</p> ]]></content:encoded> </item> <item><title>By: Tiddo</title><link>http://davidwalsh.name/create-zip-php#comment-31644</link> <dc:creator>Tiddo</dc:creator> <pubDate>Mon, 16 Apr 2012 09:41:32 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2345#comment-31644</guid> <description>No, at least not yet:
http://stackoverflow.com/questions/1833168/can-i-change-the-compression-level-of-ziparchiveAlso, you could try the method mentioned in the last post if the feature request: https://bugs.php.net/bug.php?id=41243
However, I don&#039;t know if that works, since the poster hasn&#039;t tested it, and I haven&#039;t tested it either.</description> <content:encoded><![CDATA[<p>No, at least not yet:<br
/> <a
href="http://stackoverflow.com/questions/1833168/can-i-change-the-compression-level-of-ziparchive" rel="nofollow">http://stackoverflow.com/questions/1833168/can-i-change-the-compression-level-of-ziparchive</a></p><p>Also, you could try the method mentioned in the last post if the feature request: <a
href="https://bugs.php.net/bug.php?id=41243" rel="nofollow">https://bugs.php.net/bug.php?id=41243</a><br
/> However, I don&#8217;t know if that works, since the poster hasn&#8217;t tested it, and I haven&#8217;t tested it either.</p> ]]></content:encoded> </item> <item><title>By: Rob @ Forkoff</title><link>http://davidwalsh.name/create-zip-php#comment-31305</link> <dc:creator>Rob @ Forkoff</dc:creator> <pubDate>Wed, 28 Mar 2012 08:57:48 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2345#comment-31305</guid> <description>David you are a monster... yet again, thanks from the UK.</description> <content:encoded><![CDATA[<p>David you are a monster&#8230; yet again, thanks from the UK.</p> ]]></content:encoded> </item> <item><title>By: Deepali</title><link>http://davidwalsh.name/create-zip-php#comment-30969</link> <dc:creator>Deepali</dc:creator> <pubDate>Mon, 12 Mar 2012 08:15:24 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2345#comment-30969</guid> <description>I want to upload multiple files and should be save in zip file..
can anyone tell me d php code for my requirement??</description> <content:encoded><![CDATA[<p>I want to upload multiple files and should be save in zip file..<br
/> can anyone tell me d php code for my requirement??</p> ]]></content:encoded> </item> <item><title>By: Carrie</title><link>http://davidwalsh.name/create-zip-php#comment-30665</link> <dc:creator>Carrie</dc:creator> <pubDate>Thu, 01 Mar 2012 17:11:07 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2345#comment-30665</guid> <description>I had the same error, and found it was filenames used inside the zipped folder were set to include the entire path. I modified the code to use just the file name://add the files
foreach($valid_files as $file)
{
//addFile  - http://www.php.net/manual/en/ziparchive.addfile.php
//filename - The path to the file to add.
//localname - this is the local name inside the ZIP archive that will override the filename.
$filename = basename(file);
$ext = pathinfo($file, PATHINFO_EXTENSION);
$localname = $filename.&quot;.&quot;.$ext;
//debug
echo &#039;&#039;.$file.&quot; ~ &quot;.$localname;
$zip-&gt;addFile($file,$localname);
}</description> <content:encoded><![CDATA[<p>I had the same error, and found it was filenames used inside the zipped folder were set to include the entire path. I modified the code to use just the file name:</p><p>//add the files<br
/> foreach($valid_files as $file)<br
/> {<br
/> //addFile  &#8211; <a
href="http://www.php.net/manual/en/ziparchive.addfile.php" rel="nofollow">http://www.php.net/manual/en/ziparchive.addfile.php</a><br
/> //filename &#8211; The path to the file to add.<br
/> //localname &#8211; this is the local name inside the ZIP archive that will override the filename.<br
/> $filename = basename(file);<br
/> $ext = pathinfo($file, PATHINFO_EXTENSION);<br
/> $localname = $filename.&#8221;.&#8221;.$ext;<br
/> //debug<br
/> echo &#8221;.$file.&#8221; ~ &#8220;.$localname;<br
/> $zip-&gt;addFile($file,$localname);<br
/> }</p> ]]></content:encoded> </item> <item><title>By: JamesC</title><link>http://davidwalsh.name/create-zip-php#comment-30231</link> <dc:creator>JamesC</dc:creator> <pubDate>Fri, 24 Feb 2012 16:18:16 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2345#comment-30231</guid> <description>Sorry, but this doesn&#039;t work for me... Could you give us some more sample code?I&#039;m currently using following script (obviously I&#039;ve included the big script above this):$files_to_zip = array(
ROOT_URL.$URL_ORIGINAL
);
//if true, good; if false, zip creation failed
$result = create_zip($files_to_zip,$URL_ZIP);
if($result) {
echo &#039;&lt;a href=&quot;&#039;.$URL_ZIP.&#039;&quot; rel=&quot;nofollow&quot;&gt;Download&lt;/a&gt;&#039;;
}</description> <content:encoded><![CDATA[<p>Sorry, but this doesn&#8217;t work for me&#8230; Could you give us some more sample code?</p><p>I&#8217;m currently using following script (obviously I&#8217;ve included the big script above this):</p><p> $files_to_zip = array(<br
/> ROOT_URL.$URL_ORIGINAL<br
/> );<br
/> //if true, good; if false, zip creation failed<br
/> $result = create_zip($files_to_zip,$URL_ZIP);<br
/> if($result) {<br
/> echo &#8216;<a
href="'.$URL_ZIP.'" rel="nofollow">Download</a>&#8216;;<br
/> }</p> ]]></content:encoded> </item> <item><title>By: Saving images on a webpage to a file</title><link>http://davidwalsh.name/create-zip-php#comment-29120</link> <dc:creator>Saving images on a webpage to a file</dc:creator> <pubDate>Thu, 09 Feb 2012 20:56:15 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2345#comment-29120</guid> <description>[...] some reference code to help you get started: Create a Zip File Using PHP         Your Total IT Solutions Provider!           Reply With Quote               + Reply to [...]</description> <content:encoded><![CDATA[<p>[...] some reference code to help you get started: Create a Zip File Using PHP         Your Total IT Solutions Provider!           Reply With Quote               + Reply to [...]</p> ]]></content:encoded> </item> <item><title>By: Serj</title><link>http://davidwalsh.name/create-zip-php#comment-27975</link> <dc:creator>Serj</dc:creator> <pubDate>Mon, 19 Dec 2011 15:57:25 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2345#comment-27975</guid> <description>Hi Eric =)
Thank You nice snippet.</description> <content:encoded><![CDATA[<p>Hi Eric =)<br
/> Thank You nice snippet.</p> ]]></content:encoded> </item> <item><title>By: Serj</title><link>http://davidwalsh.name/create-zip-php#comment-27974</link> <dc:creator>Serj</dc:creator> <pubDate>Mon, 19 Dec 2011 15:54:35 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2345#comment-27974</guid> <description>Hello David =)Thank You very much for useful function.Sincerely, Serj.</description> <content:encoded><![CDATA[<p>Hello David =)</p><p>Thank You very much for useful function.</p><p>Sincerely, Serj.</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching 3/7 queries in 0.009 seconds using disk: basic
Object Caching 805/805 objects using disk: basic

Served from: davidwalsh.name @ 2012-05-22 03:29:10 -->
