'detect'에 해당되는 글 1건
- 2009/07/07 PHP - Detects what compression file uses
유명한 MySQL 관리 툴이죠. phpMyAdmin 소스를 보던 중 좋은 내용을 발췌합니다.
libraries\import.lib.php 파일에 있던 내용이고요.
코드는 아래와 같습니다.
/**
* Detects what compression filse uses
*
* @param string filename to check
* @return string MIME type of compression, none for none
* @access public
*/
function PMA_detectCompression($filepath)
{
$file = @fopen($filepath, 'rb');
if (!$file) {
return FALSE;
}
$test = fread($file, 4);
$len = strlen($test);
fclose($file);
if ($len >= 2 && $test[0] == chr(31) && $test[1] == chr(139)) {
return 'application/gzip';
}
if ($len >= 3 && substr($test, 0, 3) == 'BZh') {
return 'application/bzip2';
}
if ($len >= 4 && $test == "PK\003\004") {
return 'application/zip';
}
return 'none';
}
'Program > PHP' 카테고리의 다른 글
| PHP - Detects what compression file uses (0) | 2009/07/07 |
|---|---|
| PHP on IIS 7.0, 6.0, 5.1 with Fast CGI (0) | 2009/02/01 |
| PHP : natsort() Natural order sorting 로 숫자를 제대로 정렬 (0) | 2007/05/25 |
| PHP 성능 최적화를 위한 방향 (0) | 2007/05/22 |
이 포스팅이 도움이 되었다면 구글에서 관련 정보를 찾아 보세요 ^^

Prev




