Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Uncaught Error: Call to undefined function mime_content_type() #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

okolya
Copy link

@okolya okolya commented Oct 17, 2017

related to #2

private function _mime_content_type($filename) {
$result = new finfo();

if (is_resource($result) === true) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This returns false because finfo is a class object, not a resource.

@grafikchaos
Copy link
Member

Thanks for the pull request @okolya. If you could make the following changes I'll be happy to merge your pull request in.

  • add curly braces to if/else statements
  • change the private function _mime_content_type to be protected instead
  • refactor _mime_content_type to return the mime_content_type
    /**
     * mime_content_type could be undefined
     * @see Uncaught Error: Call to undefined function mime_content_type()
     * @param $filename
     * @return string
     */
    protected function _mime_content_type($filename) 
    {
        $result = new finfo();
        return $result->file($filename, FILEINFO_MIME_TYPE);
    }

@okolya
Copy link
Author

okolya commented Oct 17, 2017

@grafikchaos Please have a look at my last commit. 8b4b51a?diff=split
It could be possible when both mime_content_type and finfo_open are not supported.

@sprankhub
Copy link

Any update?

@thomas-harding
Copy link

Just FYI, this won't work with non-PHP 7 sites as the finfo() function isn't supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants