Portrety Uliczne Nieznajomych - zobacz wyjątkową galerię portretów z warszawskich ulic
ZALOGUJ SIĘ
login:
hasło:
przypomnij hasło
załóż konto użytkownika
(i zobacz kilka porad gratis)
   
WYSZUKIWARKA I DZIAŁY
całe porady  tytuły
zaznacz działy do przeszukania
(brak wyboru = wszystkie działy)
PHP
MySQL >
PostgreSQL
SQLite
Perl
Java
XML
XSLT
XPath
WML
SVG
RegExp
Wyszukiwarki
Ochrona
VBScript
Google Plus
XHTML/CSS
JavaScript
Grafika
Flash
Photoshop
Windows
Linux
Bash
Apache
Procmail
E-biznes
Explorer
Opera
Firefox
Inne porady
   
KURSY, DOKUMENTACJE
Własne:
XHTML/CSS
JavaScript
ActionScript
WML, RSS, SSI
Pozostałe:
PHP
MySQL
Java API
więcej...
   
użytkowników online: 37
W CZYM MOGĘ POMÓC?


   
OPINIE UŻYTKOWNIKÓW
Prawdziwa skarbnica wiedzy na temat tworzenia stron WWW i nie tylko. Korzystam z porad praktycznie codziennie, jest mi to niezbędne w mojej pracy. Sam zajmuję się tworzeniem serwisów, ale porady pisane przez Darka sa dla mnie nieocenioną pomocą! Proste, czytelne i zrozumiałe dla każdego! Czekam na więcej!

Krzysztof Szypulski
KESS - projektowanie stron

   
GALERIA FOTOGRAFII
   
PODRĘCZNIK PHP 5.x, 4.x, 3.x - częściowo spolszczony / źródło: www.php.net

[Spis] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [X] [W] [Z]

LXXI. Mimetype Functions

Wstęp

Ostrzeżenie

This extension has been deprecated as the PECL extension fileinfo provides the same functionality (and more) in a much cleaner way.

The functions in this module try to guess the content type and encoding of a file by looking for certain magic byte sequences at specific positions within the file. While this is not a bullet proof approach the heuristics used do a very good job.

This extension is derived from Apache mod_mime_magic, which is itself based on the file command maintained by Ian F. Darwin. See the source code for further historic and copyright information.

Wymagania

Do zbudowania tego rozszerzenia nie są wymagane żadne zewnętrzne biblioteki.

Instalacja

You must compile PHP with the configure switch --with-mime-magic to get support for mime-type functions. The extension needs a copy of the simplified magic file that is distributed with the Apache httpd.

Notatka: The configure option has been changed from --enable-mime-magic to --with-mime-magic since PHP 4.3.2

Notatka: This extension is not capable of handling the fully decorated magic file that generally comes with standard Linux distro's and is supposed to be used with recent versions of file command.

Note to Win32 Users: In order to use this module on a Windows environment, you must set the path to the bundled magic.mime file in your php.ini.

Przykład 1. Setting the path to magic.mime

mime_magic.magicfile = "$PHP_INSTALL_DIR\magic.mime"

Remember to substitute the $PHP_INSTALL_DIR for your actual path to PHP in the above example. e.g. c:\php

Konfiguracja czasu wykonywania

Na działanie tych funcji wpływają ustawienia zawarte w pliku php.ini.

Tabela 1. Mimetype configuration options

NameDefaultChangeableChangelog
mime_magic.magicfile"/path/to/php/magic.mime"PHP_INI_SYSTEMAvailable since PHP 4.3.0.
Szczegóły i definicje dotyczące stałych PHP_INI_* znajdują się w rozdziale Dodatek H.

Typy zasobów

To rozszerzenie nie posiada żadnych rodzajów zasobów.

Stałe predefinopwane

To rozszerzenie nie posiada żadnych stałych.

Spis treści
mime_content_type -- Detect MIME Content-type for a file



User Contributed Notes

aidan at php dot net
29-Jan-2006 09:39

And the library required to get fileinfo working (named libmagic, part of libfile) is located here:
ftp://ftp.astron.com/pub/file/file-4.16.tar.gz


hans at lintoo dot dk
02-Jul-2005 03:22

When using fileinfo, I had a *lot* of problems with the mime file.

Using Apache2, FreeBSD and PHP5, I had no mime file is supply the fileinfo. So I had to use a custom mime file from a previous distribution of Apache, the files can be downloaded from here:

http://www.lintoo.dk/public/magic
and
http://www.lintoo.dk/public/magic.mime

It seems that both files are needed, although only one is supplied for fileinfo.

I used it for my file object:
<?php
   $info
= new finfo(FILEINFO_MIME,"./magic");
  
$this->fileType = $info->file($openpath);
?>

Should be rather self-explanatory, just remember to provide the path to the magic file as the second parametre when creating the fileinfo object.

I hope the originial creators of the magic files do not mind i uploaded them to http://lintoo.dk/ and share them with you. I mean no disrepect, but I cannot remember where I got the files.


blaine at blainegarrett dot com
03-Jun-2005 12:35

Some documentation on the Fileinfo PECL lib.
Didn't seem like the main site had much of anything in the way of examples, but i could be blind.

http://wiki.cc/php/Fileinfo


snarkles
23-Apr-2005 04:40

Here's an example from the source for people trying to get the fileinfo extension working with PHP 4:

<?php
$res
= finfo_open(FILEINFO_MIME); /* return mime type ala mimetype extension */
$files = glob("*");
foreach (
$files as $file) {
   echo
finfo_file($res, $file) . "\n";
}
finfo_close($res);
?>


vpopmail at engepel dot com dot br
19-Apr-2005 03:29

If you're going to install the fileinfo pecl package in a RedHat Linux 9.0 the installation will fail because the needed libmagic files are not installed by default.

They are part of the 'file' package. Even if you have file-3.39-9.rpm it doesn't provide the libraries.

You can obtain the original author's latest version of 'file' by anonymous FTP on ftp.astron.com in the directory /pub/file/file-X.YY.tar.gz.

Just extract, compile and install it in /usr/local (its default location) and you can proceed with fileinfo installation.

a big hug,
bruno negr

 

 
  © 1996-2012 & Reporter.plmiejscao serwisieabonamentwarunki korzystaniaRSSkontakt