Jump to content

Finding out file format using mime_content_type();


Love2c0de

Recommended Posts

Hello, I am designing a site which alows users to upload a certain file type, namely .dem files (gaming demo files). I have tried using mime_content_type(); but it doesn't output anything.

 

I looked at php.net and viewed the example code and tried exactly what they did. As I say, doesn't output anything though.

 

The code is:

 
<?php
  echo mime_content_type('smuggles.dem');
?>

 

I have this code in a file called test.php and the demo file is in the same folder as this file... (wamp/www)

 

php.net states the function is deprecated and advises you to use Fileinfo(). Is this the reason it doesn't work because I was advised from another forum to use the mime_content_type() function.

 

Please if you can help me I would be very grateful. I have been stuck on this for a few days now and have received no more replies from the other forum since my last post. I also thought that coming to a php dominant forum would really help my chances of achieving this.

 

Kind regards,

 

BuNgLe.

So the example code they give here:

 

 

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

 

How do I set the $filename variable to the specified file?

 

Sorry but I do not understand exactly how finfo works.

 

Regards,

 

BuNgLe.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.