Jump to content

How to get the mime type of a file


jordanwb

Recommended Posts

I tried the first one using a function that was created by someone there and I get this error:

 

Fatal error: Call to undefined function finfo_open() in D:\xampp\htdocs\jproxy\includes\file_parser.php on line 31

 

For mime_content_type I don't get any results:

 

function output ()
{
$num_lines = count ($this->html);
$mime_type = mime_content_type ($this->file);
print $mime_type;
//header("Content-type:".$mime_type);
//print_r ($this->html);
}

 

$this->file is created in the constructor and the path is correct. Perhaps mime_content_type doesn't work with files that are on another server?

Link to comment
Share on other sites

You have to have it installed and that's why I gave you this link with installation instructions: http://us2.php.net/manual/en/ref.fileinfo.php

 

The other function as per docs state that magic.mime file is needed/used.

 

The code example in the manual shows specifying a path and not a URL, so I don't think you can get the mime type from another server if that's what you're trying to do.

 

 

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.