{"id":306,"date":"2005-05-25T12:28:08","date_gmt":"2005-05-25T11:28:08","guid":{"rendered":"http:\/\/wp.devco.net\/?p=306"},"modified":"2009-10-09T17:01:00","modified_gmt":"2009-10-09T16:01:00","slug":"more_on_zip_file_creation","status":"publish","type":"post","link":"https:\/\/www.devco.net\/archives\/2005\/05\/25\/more_on_zip_file_creation.php","title":{"rendered":"More on ZIP File Creation"},"content":{"rendered":"

I did some more testing with the code I posted yesterday<\/a> and found it isn’t 100% compatible with some unzip programs. Works with unix unzip, Mac OS X default tool, WinZip, WinRAR but annoyingly not with the default XP zip folder thing.<\/p>\n

The problem seem to be 4 rogue bytes that gets inserted somewhere. So back to Google, eventually I found a much better library at PHP Concept Library Zip<\/a>. It works more or less the same, except you must pass it files to add instead of just data in variables, either works for me.<\/p>\n

Some sample code:<\/p>\n

\n
\nrequire (\"incl\/pclzip.lib.php\");\n$zipfile = new PclZip('zipfile.zip');\n$v_list = $zipfile->create('incl\/pclzip.lib.php');\nif ($v_list == 0) {\ndie (\"Error: \" . $zipfile->errorInfo(true));\n}\nheader(\"Content-type: application\/octet-stream\");\nheader(\"Content-disposition: attachment; filename=zipfile.zip\");\nreadfile(\"zipfile.zip\");\n<\/pre>\n<\/blockquote>\n

This one works with every unzip tool I’ve tried, Windows, OS X, command line unzip etc. It also has decent error reporting etc.<\/p>\n","protected":false},"excerpt":{"rendered":"

I did some more testing with the code I posted yesterday and found it isn’t 100% compatible with some unzip programs. Works with unix unzip, Mac OS X default tool, WinZip, WinRAR but annoyingly not with the default XP zip folder thing. The problem seem to be 4 rogue bytes that gets inserted somewhere. So […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","footnotes":""},"categories":[7],"tags":[121,42],"_links":{"self":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts\/306"}],"collection":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/comments?post=306"}],"version-history":[{"count":1,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts\/306\/revisions"}],"predecessor-version":[{"id":668,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts\/306\/revisions\/668"}],"wp:attachment":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/media?parent=306"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/categories?post=306"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/tags?post=306"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}