Call to undefined function DataTables\Editor\finfo_open()

Call to undefined function DataTables\Editor\finfo_open()

aarontharkeraarontharker Posts: 41Questions: 11Answers: 0

When trying to get the mime types for file uploads working I am getting this message. I am running php 5.6 so any idea what maybe causing this?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,762Questions: 1Answers: 10,111 Site admin
    Answer ✓

    In the php/Editor/Upload.php file you will be able to find:

    $finfo = finfo_open(FILEINFO_MIME);
    

    Changing that to be:

    $finfo = \finfo_open(FILEINFO_MIME);
    

    I think should resolve it.

    Could you give me the full version string for your PHP install please? I'd expected this to be a very early 5.3 release from the error message you are seeing. I'm really surprised to see it in 5.6.

    Allan

  • stevevancestevevance Posts: 58Questions: 6Answers: 1

    The error message I'm getting is

    <br />
    <b>Fatal error</b>:  Uncaught Error: Call to undefined function finfo_open() in /php/lib/Editor/Upload.php:603
    Stack trace:
    #0 /php/lib/Editor/Upload.php(431): DataTables\Editor\Upload-&gt;_dbExec(Object(DataTables\Database))
    #1 /php/lib/Editor/Editor.php(1239): DataTables\Editor\Upload-&gt;exec(Object(DataTables\Editor))
    #2 /php/lib/Editor/Editor.php(871): DataTables\Editor-&gt;_upload(Array)
    #3 /php/lib/Editor/Editor.php(661): DataTables\Editor-&gt;_process(Array)
    #4 /php/editor.files.php(182): DataTables\Editor-&gt;process(Array)
    #5 {main}
      thrown in <b>/php/lib/Editor/Upload.php</b> on line <b>603</b><br />
    

    I added the preceding backslash as you suggested and it hasn't changed anything. This is running on PHP 7.1.

  • stevevancestevevance Posts: 58Questions: 6Answers: 1
    edited August 2017

    I replaced the function in that file with mime_content_type() and that doesn't work either! That function is also not found on my PHP server, for whatever reason.

    I created an independent file with only

    <?php
    echo mime_content_type("info.php");
    ?>
    

    And this has a fatal error, indicating that the necessary functions don't exist on my server's installation of PHP.

    It turns out that Dreamhost doesn't include the correct extension by default, so I needed to add extension=fileinfo.so to my php.ini file.

  • allanallan Posts: 61,762Questions: 1Answers: 10,111 Site admin

    It sounds like the Dreamhost PHP might be a bit limited. mime_content_info is a core part of PHP. It might be worth asking Dreamhost about that.

    Allan

This discussion has been closed.