{"id":1078,"date":"2013-03-07T04:44:34","date_gmt":"2013-03-07T04:44:34","guid":{"rendered":"http:\/\/www.websitedesignwebsitedevelopment.com\/?p=1078"},"modified":"2014-03-19T09:13:43","modified_gmt":"2014-03-19T09:13:43","slug":"force-download-file-with-php-finfo","status":"publish","type":"post","link":"https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/","title":{"rendered":"Force Download File with php finfo"},"content":{"rendered":"<h2>Force Download File with php finfo<\/h2>\n<p><code>$file_info = new finfo(FILEINFO_MIME);<br \/>\n$type = $file_info-&gt;buffer(file_get_contents($zip_file));<br \/>\nheader(\"Pragma: public\");<br \/>\nheader(\"Expires: 0\");<br \/>\nheader(\"Pragma: no-cache\");<br \/>\nheader(\"Charset: null\");<br \/>\nheader(\"Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\");<br \/>\nheader(\"Content-Type: application\/force-download\");<br \/>\nheader(\"Content-Type: application\/octet-stream\");<br \/>\nheader(\"Content-Type: application\/download\");<br \/>\nheader('Content-disposition: attachment; filename=' . str_replace(' ','-', file_parts($zip_file,'name')));<br \/>\nheader(\"Content-Type: $type\");<br \/>\nheader(\"Content-Transfer-Encoding: binary\");<br \/>\nheader('Content-Length: ' . filesize($zip_file));<br \/>\n@readfile($zip_file);<br \/>\nexit(0);<\/code><\/p>\n<p>Its a revision to <a href=\"http:\/\/www.websitedesignwebsitedevelopment.com\/website-development\/files-management\/download-file-problem-due-to-version-incompatibility-of-ie-adobe-reader\/761\" title=\"Download file problem due to version incompatibility of IE &#038; Adobe Reader\">Download file problem due to version incompatibility of IE &#038; Adobe Reader<\/a><\/p>\n<p>Dependency function <a href=\"http:\/\/www.websitedesignwebsitedevelopment.com\/website-development\/php-frameworks\/codeigniter\/helper-functions\/php-explode-php-end-file-name-file-extension\/388\/\">file_parts<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Force Download File with php finfo $file_info = new finfo(FILEINFO_MIME); $type = $file_info-&gt;buffer(file_get_contents($zip_file)); header(&#8220;Pragma: public&#8221;); header(&#8220;Expires: 0&#8221;); header(&#8220;Pragma: no-cache&#8221;); header(&#8220;Charset: null&#8221;); header(&#8220;Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0&#8221;); header(&#8220;Content-Type: application\/force-download&#8221;); header(&#8220;Content-Type: application\/octet-stream&#8221;); header(&#8220;Content-Type: application\/download&#8221;); header(&#8216;Content-disposition: attachment; filename=&#8217; . str_replace(&#8216; &#8216;,&#8217;-&#8216;, file_parts($zip_file,&#8217;name&#8217;))); header(&#8220;Content-Type: $type&#8221;); header(&#8220;Content-Transfer-Encoding: binary&#8221;); header(&#8216;Content-Length: &#8216; . filesize($zip_file)); @readfile($zip_file); exit(0); Its a revision to Download [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":304,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[41],"tags":[],"class_list":["post-1078","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-files-management"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>php, mime_content_type, mime_content_type deprecated, finfo<\/title>\n<meta name=\"description\" content=\"PHP function mime_content_type is deprecated and finfo is available to get a file mime content type.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"php, mime_content_type, mime_content_type deprecated, finfo\" \/>\n<meta property=\"og:description\" content=\"PHP function mime_content_type is deprecated and finfo is available to get a file mime content type.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/\" \/>\n<meta property=\"og:site_name\" content=\"AndroidBubble Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/pages\/Website-Design-Website-Development\/172363336135453\" \/>\n<meta property=\"article:published_time\" content=\"2013-03-07T04:44:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-03-19T09:13:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2011\/09\/php_wdwd.png\" \/>\n\t<meta property=\"og:image:width\" content=\"200\" \/>\n\t<meta property=\"og:image:height\" content=\"105\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Fahad\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Fahad\" \/>\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:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/\"},\"author\":{\"name\":\"Fahad\",\"@id\":\"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7\"},\"headline\":\"Force Download File with php finfo\",\"datePublished\":\"2013-03-07T04:44:34+00:00\",\"dateModified\":\"2014-03-19T09:13:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/\"},\"wordCount\":31,\"image\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2011\/09\/php_wdwd.png\",\"articleSection\":[\"Files Management\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/\",\"url\":\"https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/\",\"name\":\"php, mime_content_type, mime_content_type deprecated, finfo\",\"isPartOf\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2011\/09\/php_wdwd.png\",\"datePublished\":\"2013-03-07T04:44:34+00:00\",\"dateModified\":\"2014-03-19T09:13:43+00:00\",\"author\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7\"},\"description\":\"PHP function mime_content_type is deprecated and finfo is available to get a file mime content type.\",\"breadcrumb\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/#primaryimage\",\"url\":\"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2011\/09\/php_wdwd.png\",\"contentUrl\":\"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2011\/09\/php_wdwd.png\",\"width\":\"200\",\"height\":\"105\",\"caption\":\"PHP: Hypertext Preprocessor\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/androidbubble.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Website Development\",\"item\":\"https:\/\/androidbubble.com\/blog\/category\/website-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Files Management\",\"item\":\"https:\/\/androidbubble.com\/blog\/category\/website-development\/files-management\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Force Download File with php finfo\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/androidbubble.com\/blog\/#website\",\"url\":\"https:\/\/androidbubble.com\/blog\/\",\"name\":\"AndroidBubble Blog\",\"description\":\"Articles &amp; Posts\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/androidbubble.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7\",\"name\":\"Fahad\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/afab5bcad71955d142a69df1758e6710aed4ab9cc2b5da28c54a7c3f39801b73?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/afab5bcad71955d142a69df1758e6710aed4ab9cc2b5da28c54a7c3f39801b73?s=96&d=mm&r=g\",\"caption\":\"Fahad\"},\"sameAs\":[\"http:\/\/www.androidbubbles.com\/\",\"https:\/\/x.com\/phpFlex\"],\"url\":\"https:\/\/androidbubble.com\/blog\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"php, mime_content_type, mime_content_type deprecated, finfo","description":"PHP function mime_content_type is deprecated and finfo is available to get a file mime content type.","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:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/","og_locale":"en_US","og_type":"article","og_title":"php, mime_content_type, mime_content_type deprecated, finfo","og_description":"PHP function mime_content_type is deprecated and finfo is available to get a file mime content type.","og_url":"https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/","og_site_name":"AndroidBubble Blog","article_publisher":"https:\/\/www.facebook.com\/pages\/Website-Design-Website-Development\/172363336135453","article_published_time":"2013-03-07T04:44:34+00:00","article_modified_time":"2014-03-19T09:13:43+00:00","og_image":[{"width":200,"height":105,"url":"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2011\/09\/php_wdwd.png","type":"image\/png"}],"author":"Fahad","twitter_misc":{"Written by":"Fahad","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/#article","isPartOf":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/"},"author":{"name":"Fahad","@id":"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7"},"headline":"Force Download File with php finfo","datePublished":"2013-03-07T04:44:34+00:00","dateModified":"2014-03-19T09:13:43+00:00","mainEntityOfPage":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/"},"wordCount":31,"image":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/#primaryimage"},"thumbnailUrl":"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2011\/09\/php_wdwd.png","articleSection":["Files Management"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/","url":"https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/","name":"php, mime_content_type, mime_content_type deprecated, finfo","isPartOf":{"@id":"https:\/\/androidbubble.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/#primaryimage"},"image":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/#primaryimage"},"thumbnailUrl":"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2011\/09\/php_wdwd.png","datePublished":"2013-03-07T04:44:34+00:00","dateModified":"2014-03-19T09:13:43+00:00","author":{"@id":"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7"},"description":"PHP function mime_content_type is deprecated and finfo is available to get a file mime content type.","breadcrumb":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/#primaryimage","url":"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2011\/09\/php_wdwd.png","contentUrl":"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2011\/09\/php_wdwd.png","width":"200","height":"105","caption":"PHP: Hypertext Preprocessor"},{"@type":"BreadcrumbList","@id":"https:\/\/androidbubble.com\/blog\/website-development\/files-management\/force-download-file-with-php-finfo\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/androidbubble.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Website Development","item":"https:\/\/androidbubble.com\/blog\/category\/website-development\/"},{"@type":"ListItem","position":3,"name":"Files Management","item":"https:\/\/androidbubble.com\/blog\/category\/website-development\/files-management\/"},{"@type":"ListItem","position":4,"name":"Force Download File with php finfo"}]},{"@type":"WebSite","@id":"https:\/\/androidbubble.com\/blog\/#website","url":"https:\/\/androidbubble.com\/blog\/","name":"AndroidBubble Blog","description":"Articles &amp; Posts","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/androidbubble.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7","name":"Fahad","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/afab5bcad71955d142a69df1758e6710aed4ab9cc2b5da28c54a7c3f39801b73?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/afab5bcad71955d142a69df1758e6710aed4ab9cc2b5da28c54a7c3f39801b73?s=96&d=mm&r=g","caption":"Fahad"},"sameAs":["http:\/\/www.androidbubbles.com\/","https:\/\/x.com\/phpFlex"],"url":"https:\/\/androidbubble.com\/blog\/author\/admin\/"}]}},"views":1055,"jetpack_featured_media_url":"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2011\/09\/php_wdwd.png","_links":{"self":[{"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/posts\/1078","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/comments?post=1078"}],"version-history":[{"count":5,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/posts\/1078\/revisions"}],"predecessor-version":[{"id":1609,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/posts\/1078\/revisions\/1609"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/media\/304"}],"wp:attachment":[{"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/media?parent=1078"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/categories?post=1078"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/tags?post=1078"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}