5

I'm making a simple call to finfo_open() and I get:

"Call to undefined function finfo_open()"

Isn't FileInfo packaged with php 5.3.3 (Unix). Do I need to turn it on in php.ini?

Thanks

Pardoner
  • 1,011
  • 4
  • 16
  • 28
  • not sure but, can you show the lines of code where u are using it? – Ibu Jun 19 '11 at 00:17
  • I am trying to do something similar in live server in WordPress maybe anyone can help me... https://stackoverflow.com/questions/57141795/enabled-fileinfo-but-still-getting-an-error-wordpress-plugin-requiement – Sayed Mohd Ali Jul 22 '19 at 09:03

2 Answers2

1

It looks like you could get it enabled but you're missing some constants. These are the values from my system:

FILEINFO_NONE = 0
FILEINFO_SYMLINK = 2
FILEINFO_MIME = 1040
FILEINFO_MIME_TYPE = 16
FILEINFO_MIME_ENCODING = 1024
FILEINFO_DEVICES = 8
FILEINFO_CONTINUE = 32
FILEINFO_PRESERVE_ATIME = 128
FILEINFO_RAW = 256

Maybe it helps.

hakre
  • 193,403
  • 52
  • 435
  • 836
  • I don't know where these constants ought to be, but adding them to php.ini did the trick for me. – user508402 Feb 11 '20 at 13:56
  • @user508402: How does adding constants in the php.ini work? With the `auto_prepend_file` directive? – hakre Feb 12 '20 at 06:08
0

Depends really, the php on your server might have been compiled without it for some reason.

create a new .php file and put the infamous <? phpinfo(); ?> and check to see if that extension is compiled in.

Vinicius Kamakura
  • 7,665
  • 1
  • 29
  • 43
  • Looks like "SplFileInfo" is enabled (not sure if thats the same thing though). Under "Configure Command" it says: '--disable-fileinfo'. – Pardoner Jun 19 '11 at 00:22
  • well, it's disabled :) Nothing to do about it in that particular server – Vinicius Kamakura Jun 19 '11 at 00:23
  • 1
    @Pardoner: No, that's a different thing. SplFileObject and SplFileInfo have nothing to do with it. But the --disable switch pertains to the `finfo` extension. You could still install it as separate module, if you find/compile it. http://pecl.php.net/package/Fileinfo – mario Jun 19 '11 at 00:26
  • I "pecl install fileinfo", which was successful. But still no change in phpinfo(). – Pardoner Jun 19 '11 at 00:27
  • 1
    @Pardoner: Check php.ini for extension= load line. And restart Apache. Otherwise it wouldn't have any effect. – mario Jun 19 '11 at 00:29
  • you need to reconfigure, recompile the whole php to make it work – Vinicius Kamakura Jun 19 '11 at 00:29
  • @mario, Yes I restarted apache. Do I need to put the path to the extension in the php.ini? – Pardoner Jun 19 '11 at 00:32
  • 1
    @Pardoner: Preferrably. Linux binaries use an extra `/etc/php5/*/conf.d/` set of *.ini files. Check if it's there. – mario Jun 19 '11 at 00:34
  • Do I need something like this: `mime_magic.magicfile = "/usr/share/file/magic.mime" extension=fileinfo.so` – Pardoner Jun 19 '11 at 00:34
  • I added the above lines to php.ini and restarted apache. phpinfo() now shows "fileinfo support: enabled" (still says '--disable-fileinfo' under configure command!!??). After calling finfo_open(FILEINFO_MIME_TYPE) i get "finfo_open() expects parameter 1 to be long, string given..." – Pardoner Jun 19 '11 at 00:43
  • 1
    @Pardoner: Looks like the constant `FILEINFO_MIME_TYPE` is not defined. You could cross-check that with `var_dump(get_defined_constants(1));`. – hakre Jun 19 '11 at 01:25
  • the `configure command` are the parameters you pass to the configure script. it will NEVER change, unless you reconfigure and recompile php (ie: ./configure ; make). – Vinicius Kamakura Jun 19 '11 at 01:30