{"id":708381,"date":"2020-04-21T13:08:46","date_gmt":"2020-04-21T13:08:46","guid":{"rendered":"https:\/\/www.knowband.com\/blog\/?p=708381\/"},"modified":"2020-04-21T22:38:46","modified_gmt":"2020-04-21T13:08:46","slug":"zipping-issue-last-file-not-zipping","status":"publish","type":"post","link":"https:\/\/www.knowband.com\/blog\/tips\/zipping-issue-last-file-not-zipping\/","title":{"rendered":"Zipping Issue: Last File is not zipping"},"content":{"rendered":"<h2>Objective of the blog:<\/h2>\n<p>The objective of this blog is to help you know how to fix the issue \u2013\u201c<strong>last file is not zipping<\/strong>\u201d. If you are facing the same issue then this blog will help you. Example- If there are 4 text files then only 3 files are zipping.<\/p>\n<h2>Reason for this\u00a0issue:<\/h2>\n<p>The\u00a0zip_close($zip)\u00a0function is not working due to which the file was unlinking before creating zip.<\/p>\n<h2>Solution:<\/h2>\n<p>You need to replace\u00a0zip_close($zip)\u00a0by\u00a0$zip-&gt;close() to fix this issue.<\/p>\n<p>Sample Code is given below:<\/p>\n<pre class=\"brush: actionscript3; gutter: true\">$zip = new ZipArchive();\r\n\/\/ zip 2 days older files\r\nforeach (glob($directory. &#039;\/*.txt&#039;) as $a_file) {\r\nif (filemtime($a_file) &lt; time() - 172800) { \/\/2 days older 172800\r\n$filename_array = explode(&quot;\/&quot;, $a_file);\r\n$key = sizeof($filename_array) - 1;\r\n$filename = $filename_array[$key];\r\n$source_path = $directory.&#039;\/&#039;;\r\n$zip_file = $source_path.str_replace(&#039;.txt&#039;,&#039;&#039;,$filename).&quot;.zip&quot;;\r\nif ($zip-&gt;open($zip_file, ZipArchive::CREATE) !== TRUE) {\r\nexit(&quot;cannot open&quot;.$zip_file.&quot;\\n&quot;);\r\n}\r\n$zip-&gt;addFile($a_file,$filename);\r\n}\r\n}\r\n$zip-&gt;close(); \/\/ Replaced zip_close($zip) by $zip-&gt;close();\r\n\r\n\/\/ Move 90 days olders in the Archive and remove the files which are older than 180 days\r\nforeach (glob($directory.&#039;\/*.zip&#039;) as $a_file) {\r\n\/\/ remove files which older than 180 days.\r\nif (filemtime($a_file) &lt; time() - 15552000) { \/\/180 days older 15552000\r\nunlink($a_file);\r\n}\r\n}<\/pre>\n<h2>Summary<\/h2>\n<p>In this blog, we have changed the zipping close function in order to fix the given issue.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Objective of the blog: The objective of this blog is to help you know how to fix the issue \u2013\u201clast file is not zipping\u201d. If you are facing the same issue then this blog will help you. Example- If there are 4 text files then only 3 files are zipping. Reason for this\u00a0issue: The\u00a0zip_close($zip)\u00a0function is [&hellip;]<\/p>\n","protected":false},"author":19,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_kbui_enabled":"","footnotes":""},"categories":[1111],"tags":[22144,19987,22145],"class_list":["post-708381","post","type-post","status-publish","format-standard","hentry","category-tips","tag-last-file-is-not-zipping","tag-solution","tag-zipping-issue"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Zipping Issue: Last File is not zipping | Technical Blog<\/title>\n<meta name=\"description\" content=\"If you are facing the issue \u201clast file is not zipping\u201d then this blog will help you. Example- If there are 4 text files then only 3 files are zipping.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.knowband.com\/blog\/tips\/zipping-issue-last-file-not-zipping\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Zipping Issue: Last File is not zipping | Technical Blog\" \/>\n<meta property=\"og:description\" content=\"If you are facing the issue \u201clast file is not zipping\u201d then this blog will help you. Example- If there are 4 text files then only 3 files are zipping.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.knowband.com\/blog\/tips\/zipping-issue-last-file-not-zipping\/\" \/>\n<meta property=\"og:site_name\" content=\"Knowband Blog | Ecommerce Modules\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Knowband\" \/>\n<meta property=\"article:published_time\" content=\"2020-04-21T13:08:46+00:00\" \/>\n<meta name=\"author\" content=\"Shivam Verma\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@KnowbandPlugin\" \/>\n<meta name=\"twitter:site\" content=\"@KnowbandPlugin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Shivam Verma\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/tips\\\/zipping-issue-last-file-not-zipping\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/tips\\\/zipping-issue-last-file-not-zipping\\\/\"},\"author\":{\"name\":\"Shivam Verma\",\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/fr\\\/#\\\/schema\\\/person\\\/e053c57d62fceb4295302b9293e371f6\"},\"headline\":\"Zipping Issue: Last File is not zipping\",\"datePublished\":\"2020-04-21T13:08:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/tips\\\/zipping-issue-last-file-not-zipping\\\/\"},\"wordCount\":116,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/fr\\\/#organization\"},\"keywords\":[\"last file is not zipping\",\"solution\",\"Zipping issue\"],\"articleSection\":[\"Tips\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/tips\\\/zipping-issue-last-file-not-zipping\\\/\",\"url\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/tips\\\/zipping-issue-last-file-not-zipping\\\/\",\"name\":\"Zipping Issue: Last File is not zipping | Technical Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/fr\\\/#website\"},\"datePublished\":\"2020-04-21T13:08:46+00:00\",\"description\":\"If you are facing the issue \u201clast file is not zipping\u201d then this blog will help you. Example- If there are 4 text files then only 3 files are zipping.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/tips\\\/zipping-issue-last-file-not-zipping\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.knowband.com\\\/blog\\\/tips\\\/zipping-issue-last-file-not-zipping\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/tips\\\/zipping-issue-last-file-not-zipping\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/fr\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Zipping Issue: Last File is not zipping\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/fr\\\/#website\",\"url\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/fr\\\/\",\"name\":\"Knowband Blog | Ecommerce Modules\",\"description\":\"Magento, Prestashop, Opencart, Shopify\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/fr\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/fr\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/fr\\\/#organization\",\"name\":\"Knowband Blog | Ecommerce Modules\",\"url\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/fr\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/fr\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/09\\\/cropped-knowband_logo-v2.png\",\"contentUrl\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/09\\\/cropped-knowband_logo-v2.png\",\"width\":153,\"height\":61,\"caption\":\"Knowband Blog | Ecommerce Modules\"},\"image\":{\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/fr\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/Knowband\",\"https:\\\/\\\/x.com\\\/KnowbandPlugin\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/fr\\\/#\\\/schema\\\/person\\\/e053c57d62fceb4295302b9293e371f6\",\"name\":\"Shivam Verma\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/02\\\/Image_for_blogShivam-150x150.jpg\",\"url\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/02\\\/Image_for_blogShivam-150x150.jpg\",\"contentUrl\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/02\\\/Image_for_blogShivam-150x150.jpg\",\"caption\":\"Shivam Verma\"},\"description\":\"Shivam Verma is an experienced software engineer in PHP development and Database design. His area of interest is website development. He likes to be aware of his surroundings and to learn new things by observing others. He believes that by doing this we can learn new things and can also enhance our knowledge everyday. He has started writing technical blogs with a view to help others in studying and learning new things in an easy way.\",\"url\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/author\\\/sverma\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Zipping Issue: Last File is not zipping | Technical Blog","description":"If you are facing the issue \u201clast file is not zipping\u201d then this blog will help you. Example- If there are 4 text files then only 3 files are zipping.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.knowband.com\/blog\/tips\/zipping-issue-last-file-not-zipping\/","og_locale":"en_US","og_type":"article","og_title":"Zipping Issue: Last File is not zipping | Technical Blog","og_description":"If you are facing the issue \u201clast file is not zipping\u201d then this blog will help you. Example- If there are 4 text files then only 3 files are zipping.","og_url":"https:\/\/www.knowband.com\/blog\/tips\/zipping-issue-last-file-not-zipping\/","og_site_name":"Knowband Blog | Ecommerce Modules","article_publisher":"https:\/\/www.facebook.com\/Knowband","article_published_time":"2020-04-21T13:08:46+00:00","author":"Shivam Verma","twitter_card":"summary_large_image","twitter_creator":"@KnowbandPlugin","twitter_site":"@KnowbandPlugin","twitter_misc":{"Written by":"Shivam Verma","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.knowband.com\/blog\/tips\/zipping-issue-last-file-not-zipping\/#article","isPartOf":{"@id":"https:\/\/www.knowband.com\/blog\/tips\/zipping-issue-last-file-not-zipping\/"},"author":{"name":"Shivam Verma","@id":"https:\/\/www.knowband.com\/blog\/fr\/#\/schema\/person\/e053c57d62fceb4295302b9293e371f6"},"headline":"Zipping Issue: Last File is not zipping","datePublished":"2020-04-21T13:08:46+00:00","mainEntityOfPage":{"@id":"https:\/\/www.knowband.com\/blog\/tips\/zipping-issue-last-file-not-zipping\/"},"wordCount":116,"commentCount":0,"publisher":{"@id":"https:\/\/www.knowband.com\/blog\/fr\/#organization"},"keywords":["last file is not zipping","solution","Zipping issue"],"articleSection":["Tips"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.knowband.com\/blog\/tips\/zipping-issue-last-file-not-zipping\/","url":"https:\/\/www.knowband.com\/blog\/tips\/zipping-issue-last-file-not-zipping\/","name":"Zipping Issue: Last File is not zipping | Technical Blog","isPartOf":{"@id":"https:\/\/www.knowband.com\/blog\/fr\/#website"},"datePublished":"2020-04-21T13:08:46+00:00","description":"If you are facing the issue \u201clast file is not zipping\u201d then this blog will help you. Example- If there are 4 text files then only 3 files are zipping.","breadcrumb":{"@id":"https:\/\/www.knowband.com\/blog\/tips\/zipping-issue-last-file-not-zipping\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.knowband.com\/blog\/tips\/zipping-issue-last-file-not-zipping\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.knowband.com\/blog\/tips\/zipping-issue-last-file-not-zipping\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.knowband.com\/blog\/fr\/"},{"@type":"ListItem","position":2,"name":"Zipping Issue: Last File is not zipping"}]},{"@type":"WebSite","@id":"https:\/\/www.knowband.com\/blog\/fr\/#website","url":"https:\/\/www.knowband.com\/blog\/fr\/","name":"Knowband Blog | Ecommerce Modules","description":"Magento, Prestashop, Opencart, Shopify","publisher":{"@id":"https:\/\/www.knowband.com\/blog\/fr\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.knowband.com\/blog\/fr\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.knowband.com\/blog\/fr\/#organization","name":"Knowband Blog | Ecommerce Modules","url":"https:\/\/www.knowband.com\/blog\/fr\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.knowband.com\/blog\/fr\/#\/schema\/logo\/image\/","url":"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2016\/09\/cropped-knowband_logo-v2.png","contentUrl":"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2016\/09\/cropped-knowband_logo-v2.png","width":153,"height":61,"caption":"Knowband Blog | Ecommerce Modules"},"image":{"@id":"https:\/\/www.knowband.com\/blog\/fr\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/Knowband","https:\/\/x.com\/KnowbandPlugin"]},{"@type":"Person","@id":"https:\/\/www.knowband.com\/blog\/fr\/#\/schema\/person\/e053c57d62fceb4295302b9293e371f6","name":"Shivam Verma","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2019\/02\/Image_for_blogShivam-150x150.jpg","url":"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2019\/02\/Image_for_blogShivam-150x150.jpg","contentUrl":"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2019\/02\/Image_for_blogShivam-150x150.jpg","caption":"Shivam Verma"},"description":"Shivam Verma is an experienced software engineer in PHP development and Database design. His area of interest is website development. He likes to be aware of his surroundings and to learn new things by observing others. He believes that by doing this we can learn new things and can also enhance our knowledge everyday. He has started writing technical blogs with a view to help others in studying and learning new things in an easy way.","url":"https:\/\/www.knowband.com\/blog\/author\/sverma\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.knowband.com\/blog\/wp-json\/wp\/v2\/posts\/708381","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.knowband.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.knowband.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.knowband.com\/blog\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/www.knowband.com\/blog\/wp-json\/wp\/v2\/comments?post=708381"}],"version-history":[{"count":1,"href":"https:\/\/www.knowband.com\/blog\/wp-json\/wp\/v2\/posts\/708381\/revisions"}],"predecessor-version":[{"id":708382,"href":"https:\/\/www.knowband.com\/blog\/wp-json\/wp\/v2\/posts\/708381\/revisions\/708382"}],"wp:attachment":[{"href":"https:\/\/www.knowband.com\/blog\/wp-json\/wp\/v2\/media?parent=708381"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.knowband.com\/blog\/wp-json\/wp\/v2\/categories?post=708381"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.knowband.com\/blog\/wp-json\/wp\/v2\/tags?post=708381"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}