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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.