Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>A. You can start by trying </p> <pre><code> mime_content_type('zip:///path/to/file.zip#'. $chapterZip-&gt;getNameIndex ( $i )); </code></pre> <p>B. What i can only think of now is a replacement for <code>mime_content_type</code> it might not be the best approach but am sure it would surface till i figure out a better solution</p> <pre><code>$chapterZip = new ZipArchive (); if ($chapterZip-&gt;open ( "stockoverflow.zip" )) { for($i = 0; $i &lt; $chapterZip-&gt;numFiles; $i ++) { var_dump ( mime_content_type_replacement ( $chapterZip-&gt;getNameIndex ( $i ) ) ); } } </code></pre> <p><strong>Replacement Function using <code>file extension</code> and <code>finfo_open ( FILEINFO_MIME )</code></strong></p> <pre><code>function mime_content_type_replacement($filename) { $mime_types = array ( 'txt' =&gt; 'text/plain', 'htm' =&gt; 'text/html', 'html' =&gt; 'text/html', 'php' =&gt; 'text/html', 'css' =&gt; 'text/css', 'js' =&gt; 'application/javascript', 'json' =&gt; 'application/json', 'xml' =&gt; 'application/xml', 'swf' =&gt; 'application/x-shockwave-flash', 'flv' =&gt; 'video/x-flv', // images 'png' =&gt; 'image/png', 'jpe' =&gt; 'image/jpeg', 'jpeg' =&gt; 'image/jpeg', 'jpg' =&gt; 'image/jpeg', 'gif' =&gt; 'image/gif', 'bmp' =&gt; 'image/bmp', 'ico' =&gt; 'image/vnd.microsoft.icon', 'tiff' =&gt; 'image/tiff', 'tif' =&gt; 'image/tiff', 'svg' =&gt; 'image/svg+xml', 'svgz' =&gt; 'image/svg+xml', // archives 'zip' =&gt; 'application/zip', 'rar' =&gt; 'application/x-rar-compressed', 'exe' =&gt; 'application/x-msdownload', 'msi' =&gt; 'application/x-msdownload', 'cab' =&gt; 'application/vnd.ms-cab-compressed', // audio/video 'mp3' =&gt; 'audio/mpeg', 'qt' =&gt; 'video/quicktime', 'mov' =&gt; 'video/quicktime', // adobe 'pdf' =&gt; 'application/pdf', 'psd' =&gt; 'image/vnd.adobe.photoshop', 'ai' =&gt; 'application/postscript', 'eps' =&gt; 'application/postscript', 'ps' =&gt; 'application/postscript', // ms office 'doc' =&gt; 'application/msword', 'rtf' =&gt; 'application/rtf', 'xls' =&gt; 'application/vnd.ms-excel', 'ppt' =&gt; 'application/vnd.ms-powerpoint', // open office 'odt' =&gt; 'application/vnd.oasis.opendocument.text', 'ods' =&gt; 'application/vnd.oasis.opendocument.spreadsheet' ); $ext = pathinfo ( $filename, PATHINFO_EXTENSION ); if (array_key_exists ( $ext, $mime_types )) { return $mime_types [$ext]; } elseif (function_exists ( 'finfo_open' )) { $finfo = finfo_open ( FILEINFO_MIME ); $mimetype = finfo_file ( $finfo, $filename ); finfo_close ( $finfo ); return $mimetype; } else { return 'application/octet-stream'; } } </code></pre> <p>Fore more mime types </p> <p><a href="https://stackoverflow.com/questions/7519393/php-mime-types-list-of-mime-types-publically-available">PHP / Mime Types - List of mime types publically available?</a></p> <p><a href="http://snipplr.com/view/1937/" rel="nofollow noreferrer">http://snipplr.com/view/1937/</a> </p> <p><strong>Edit 1</strong></p> <p>Just tested the following and it works </p> <pre><code>$fp = fopen('zip://C:\stockoverflow.zip#1.MOV.xml',"r"); </code></pre> <p><strong>Edit 2</strong></p> <p>A. <code>mime_content_type($fp)</code> would not work because <code>mime_content_type</code> only accept string argument see <a href="http://php.net/manual/en/function.mime-content-type.php" rel="nofollow noreferrer">http://php.net/manual/en/function.mime-content-type.php</a></p> <p>B. Am not sure why you are still sticking to <code>mime_content_type</code> because it has also been depreciated </p> <blockquote> <p>This function has been deprecated as the PECL extension Fileinfo provides the same functionality (and more) in a much cleaner way.</p> </blockquote> <p>C. working on <code>$fileatt['tmp_name']</code> directly is not ideal .. its a temp file and not to be manipulated .. for you to work on that file you need it to copy it to the server where your PHP would have full permission to access it </p> <p>D. <code>ZipArchive::getStream</code> would only work on a local copy of the <code>zip</code> file not temporary upload file </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload