but. You can start by using
mime_content_type('zip:///path/to/file.zip#'. $chapterZip->getNameIndex ( $i ));
Q. Now I can only think about replacing mime_content_type , this may not be the best approach, but I'm sure it will be displayed until I figure out the best solution
$chapterZip = new ZipArchive (); if ($chapterZip->open ( "stockoverflow.zip" )) { for($i = 0; $i < $chapterZip->numFiles; $i ++) { var_dump ( mime_content_type_replacement ( $chapterZip->getNameIndex ( $i ) ) ); } }
Replace function using file extension and finfo_open ( FILEINFO_MIME )
function mime_content_type_replacement($filename) { $mime_types = array ( 'txt' => 'text/plain', 'htm' => 'text/html', 'html' => 'text/html', 'php' => 'text/html', 'css' => 'text/css', 'js' => 'application/javascript', 'json' => 'application/json', 'xml' => 'application/xml', 'swf' => 'application/x-shockwave-flash', 'flv' => 'video/x-flv', // images 'png' => 'image/png', 'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'gif' => 'image/gif', 'bmp' => 'image/bmp', 'ico' => 'image/vnd.microsoft.icon', 'tiff' => 'image/tiff', 'tif' => 'image/tiff', 'svg' => 'image/svg+xml', 'svgz' => 'image/svg+xml', // archives 'zip' => 'application/zip', 'rar' => 'application/x-rar-compressed', 'exe' => 'application/x-msdownload', 'msi' => 'application/x-msdownload', 'cab' => 'application/vnd.ms-cab-compressed', // audio/video 'mp3' => 'audio/mpeg', 'qt' => 'video/quicktime', 'mov' => 'video/quicktime', // adobe 'pdf' => 'application/pdf', 'psd' => 'image/vnd.adobe.photoshop', 'ai' => 'application/postscript', 'eps' => 'application/postscript', 'ps' => 'application/postscript', // ms office 'doc' => 'application/msword', 'rtf' => 'application/rtf', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', // open office 'odt' => 'application/vnd.oasis.opendocument.text', 'ods' => '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'; } }
More mime types
PHP / Mime Types - List of available mime types?
http://snipplr.com/view/1937/
Change 1
Just tested the following and it works
$fp = fopen('zip://C:\stockoverflow.zip#1.MOV.xml',"r");
Edit 2
but. mime_content_type($fp) does not work because mime_content_type only accepts a string argument, see http://php.net/manual/en/function.mime-content-type.php
B. Not sure why you are still sticking to mime_content_type , because it was also depreciated
This feature is deprecated since the PECL Fileinfo extension provides much more efficient functionality (and much more).
C. work on $fileatt['tmp_name'] directly is not ideal .. its temporary file does not need to be manipulated .. in order for you to work on this file, you need to copy it to a server where your PHP will have full permission to access to it
D. ZipArchive::getStream will only work with a local copy of a zip file not a temporary download file