<?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>Thu, 09 Feb 2012 02:40:12 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3</generator> <item><title>By: Serj</title><link>http://davidwalsh.name/create-zip-php/comment-page-1#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-page-1#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> <item><title>By: Lolki</title><link>http://davidwalsh.name/create-zip-php/comment-page-1#comment-26682</link> <dc:creator>Lolki</dc:creator> <pubDate>Tue, 23 Aug 2011 12:15:33 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2345#comment-26682</guid> <description>Doesnt help me much if you dont output some debug info. Uncomment them in the code.</description> <content:encoded><![CDATA[<p>Doesnt help me much if you dont output some debug info. Uncomment them in the code.</p> ]]></content:encoded> </item> <item><title>By: saranya</title><link>http://davidwalsh.name/create-zip-php/comment-page-1#comment-26681</link> <dc:creator>saranya</dc:creator> <pubDate>Tue, 23 Aug 2011 12:01:56 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2345#comment-26681</guid> <description>In linux server zip file will not create..above code is used by me in linux sever...</description> <content:encoded><![CDATA[<p>In linux server zip file will not create..above code is used by me in linux sever&#8230;</p> ]]></content:encoded> </item> <item><title>By: saranya</title><link>http://davidwalsh.name/create-zip-php/comment-page-1#comment-26680</link> <dc:creator>saranya</dc:creator> <pubDate>Tue, 23 Aug 2011 11:57:01 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2345#comment-26680</guid> <description>sorry pls ignore the code..</description> <content:encoded><![CDATA[<p>sorry pls ignore the code..</p> ]]></content:encoded> </item> <item><title>By: saranya</title><link>http://davidwalsh.name/create-zip-php/comment-page-1#comment-26679</link> <dc:creator>saranya</dc:creator> <pubDate>Tue, 23 Aug 2011 11:56:05 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2345#comment-26679</guid> <description>hi..I just want to download the files in the format of zip...using this code i can zip the files and download the same files..this is working fine in my windows..but am trying to work with linux server..this code is not working properly..
i got a error below,
Warning
---------------------------
No archives found
---------------------------
This is my code..../* creates a compressed zip file */
function create_zip($files = array(),$destination = &#039;&#039;,$overwrite = false) {
//if the zip file already exists and overwrite is false, return false
if(file_exists($destination) &amp;&amp; !$overwrite) { return false; }
//vars
$valid_files = array();
//if files were passed in...
if(is_array($files)) {
//cycle through each file
foreach($files as $file) {
//make sure the file exists
if(file_exists($file)) {
$valid_files[] = $file;
}
}
}
//if we have good files...
if(count($valid_files)) {
//create the archive
$zip = new ZipArchive();
if($zip-&gt;open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {
return false;
}
//add the files
foreach($valid_files as $file) {
$zip-&gt;addFile($file,basename($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;
}
}// get files
$fileid=HttpRequest::GetRequestParm(&#039;fileid&#039;);
$object_common = new  FUS_COMMON_UPLOAD_FILE();
$res = array();
$res = $object_common-&gt;viewFiles($fileid);
$fileNames=explode(&quot;,&quot;,$res[0][&#039;FCUF_FILE_NAME&#039;]);
$path=ROOTPATH.&#039;upload/common_file_upload/&#039;;
foreach($fileNames as $file){
$files_to_zip[]=$path.$file;
}
/*$files_to_zip = array(
&#039;multiple-file-upload/change-log.txt&#039;,
&#039;multiple-file-upload/documentation.css&#039;,
);*///print_pre($files_to_zip); exit;//if true, good; if false, zip creation failed
$result = create_zip($files_to_zip,&#039;multi_files.zip&#039;,true);//$fileName = trim($_REQUEST[&#039;fileName&#039;]);
$fileName = &quot;multi_files.zip&quot;;
header(&#039;Content-type: application/octet-stream&#039;);
header(&#039;Content-Disposition: attachment;filename=&#039;.$fileName);
header(&#039;Pragma: no-cache&#039;);
header(&#039;Expires: 0&#039;);
header(&#039;Content-Transfer-Encoding: binary&#039;);
header(&#039;Content-length: &#039;.filesize($fileName));
ob_clean();
flush();
readfile($fileName);pls help..thanx lolki..</description> <content:encoded><![CDATA[<p>hi..I just want to download the files in the format of zip&#8230;using this code i can zip the files and download the same files..this is working fine in my windows..but am trying to work with linux server..this code is not working properly..<br
/> i got a error below,</p><p>Warning<br
/> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br
/> No archives found<br
/> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br
/> This is my code&#8230;.</p><p>/* creates a compressed zip file */<br
/> function create_zip($files = array(),$destination = &#8221;,$overwrite = false) {<br
/> //if the zip file already exists and overwrite is false, return false<br
/> if(file_exists($destination) &amp;&amp; !$overwrite) { return false; }<br
/> //vars<br
/> $valid_files = array();<br
/> //if files were passed in&#8230;<br
/> if(is_array($files)) {<br
/> //cycle through each file<br
/> foreach($files as $file) {<br
/> //make sure the file exists<br
/> if(file_exists($file)) {<br
/> $valid_files[] = $file;<br
/> }<br
/> }<br
/> }<br
/> //if we have good files&#8230;<br
/> if(count($valid_files)) {<br
/> //create the archive<br
/> $zip = new ZipArchive();<br
/> if($zip-&gt;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,basename($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>// get files<br
/> $fileid=HttpRequest::GetRequestParm(&#8216;fileid&#8217;);<br
/> $object_common = new  FUS_COMMON_UPLOAD_FILE();<br
/> $res = array();<br
/> $res = $object_common-&gt;viewFiles($fileid);<br
/> $fileNames=explode(&#8220;,&#8221;,$res[0]['FCUF_FILE_NAME']);<br
/> $path=ROOTPATH.&#8217;upload/common_file_upload/&#8217;;<br
/> foreach($fileNames as $file){<br
/> $files_to_zip[]=$path.$file;<br
/> }<br
/> /*$files_to_zip = array(<br
/> &#8216;multiple-file-upload/change-log.txt&#8217;,<br
/> &#8216;multiple-file-upload/documentation.css&#8217;,<br
/> );*/</p><p>//print_pre($files_to_zip); exit;</p><p>//if true, good; if false, zip creation failed<br
/> $result = create_zip($files_to_zip,&#8217;multi_files.zip&#8217;,true);</p><p>//$fileName = trim($_REQUEST['fileName']);<br
/> $fileName = &#8220;multi_files.zip&#8221;;<br
/> header(&#8216;Content-type: application/octet-stream&#8217;);<br
/> header(&#8216;Content-Disposition: attachment;filename=&#8217;.$fileName);<br
/> header(&#8216;Pragma: no-cache&#8217;);<br
/> header(&#8216;Expires: 0&#8242;);<br
/> header(&#8216;Content-Transfer-Encoding: binary&#8217;);<br
/> header(&#8216;Content-length: &#8216;.filesize($fileName));<br
/> ob_clean();<br
/> flush();<br
/> readfile($fileName);</p><p>pls help..thanx lolki..</p> ]]></content:encoded> </item> <item><title>By: Lolki</title><link>http://davidwalsh.name/create-zip-php/comment-page-1#comment-26678</link> <dc:creator>Lolki</dc:creator> <pubDate>Tue, 23 Aug 2011 11:42:48 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2345#comment-26678</guid> <description>Saranya. If you dont give more information, nobody will help you.
What is your problem? Did you try to print some debugging variables? What does it say?</description> <content:encoded><![CDATA[<p>Saranya. If you dont give more information, nobody will help you.<br
/> What is your problem? Did you try to print some debugging variables? What does it say?</p> ]]></content:encoded> </item> <item><title>By: saranya</title><link>http://davidwalsh.name/create-zip-php/comment-page-1#comment-26677</link> <dc:creator>saranya</dc:creator> <pubDate>Tue, 23 Aug 2011 11:29:22 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2345#comment-26677</guid> <description>hi,
thanx for the code..really working fine in windows..but this same code not working when i use linux...pls help this problem..thanx in advanceRegards,
saran..</description> <content:encoded><![CDATA[<p>hi,<br
/> thanx for the code..really working fine in windows..but this same code not working when i use linux&#8230;pls help this problem..thanx in advance</p><p>Regards,<br
/> saran..</p> ]]></content:encoded> </item> <item><title>By: tttony</title><link>http://davidwalsh.name/create-zip-php/comment-page-1#comment-26642</link> <dc:creator>tttony</dc:creator> <pubDate>Sun, 21 Aug 2011 22:07:20 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2345#comment-26642</guid> <description>Very good!!The copy function does not works very well, copy the code but doing some changes inside the code</description> <content:encoded><![CDATA[<p>Very good!!</p><p>The copy function does not works very well, copy the code but doing some changes inside the code</p> ]]></content:encoded> </item> <item><title>By: Granados</title><link>http://davidwalsh.name/create-zip-php/comment-page-1#comment-26163</link> <dc:creator>Granados</dc:creator> <pubDate>Thu, 21 Jul 2011 16:12:26 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2345#comment-26163</guid> <description>Whops, sorry, I made a mistake, instead of the double dots, put a single one inside the if.</description> <content:encoded><![CDATA[<p>Whops, sorry, I made a mistake, instead of the double dots, put a single one inside the if.</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 1/18 queries in 0.019 seconds using disk: basic
Object Caching 865/868 objects using disk: basic

Served from: davidwalsh.name @ 2012-02-09 00:42:49 -->
