Truemag

  • Categories
    • Tips And Tricks
    • Internet
    • PHP
    • Javascript
    • CSharp
    • SQL Server
    • Linux
  • Lastest Videos
  • Our Demos
  • About
  • Contact
  • Home
  • Write With Us
  • Job Request
Home PHP Get File Mime Type Using PHP

Get File Mime Type Using PHP

PHP has a function call mime_content_type (string $filename) that detect mime type (content type) of a particular file. This function is extremely useful when we try to download a file from an online URL or we don’t know exactly what extension/mime type of the file is.

According to a question from Greg Newman in PHP Download Image Or File From URL article:

What can one do when the $file_url is not fully qualified and does not directly point to a file.zip but rather points to a page that itself forces download of a file.zip.

In this scenario, he try to download a file from an external URL but the file name is not specified. It’s generated on the server and forces download. Therefore, we need to determine its mime type by using mime_content_type PHP function then rename that file to a corresponding extension.

PHP Function Detect Mime Type Of A File

<?php
string mime_content_type ( string $filename )
?>

<?php string mime_content_type ( string $filename ) ?>

Feb 2, 2012Hoan Huynh
Set Default Home Page For Google Chrome, Firefox, Internet Explorer And SafariValidate email using regular expression in ASP.NET
You Might Also Like:
  • Add Mime Type (.FLV, .MP4) In IIS For A Website Or Global
  • Add Mime Type (.FLV, MP4) To Web.Config In IIS 7
  • PHP Get Remote File Size And Content Type
  • PHP Download Image Or File From URL
  • PHP Delete File Function
  • C# Check File Extension In Array Of Valid Extension
  • PHP Save String Content To File
  • Get Image Width Height With JQuery And JavaScript
  • Google Map Supported Type And Simple Example
  • How To Track Website With Multiple Google Analytisc Accounts
Hoan Huynh

Hoan Huynh is the founder and head of 4rapiddev.com. Reach him at [email protected]

10 years ago PHPMime Type, mime_content_type383
0
GooglePlus
0
Facebook
0
Twitter
0
Digg
0
Delicious
0
Stumbleupon
0
Linkedin
0
Pinterest
Most Viewed
PHP Download Image Or File From URL
24,554 views
Notepad Plus Plus Compare Plugin
How To Install Compare Text Plugin In Notepad Plus Plus
21,892 views
Microsoft SQL Server 2008 Attach Remove Log
Delete, Shrink, Eliminate Transaction Log .LDF File
17,745 views
JQuery Allow only numeric characters or only alphabet characters in textbox
15,069 views
C# Read Json From URL And Parse/Deserialize Json
11,802 views
4 Rapid Development is a central page that is targeted at newbie and professional programmers, database administrators, system admin, web masters and bloggers.
Recent Posts
  • Things to Learn about Installingderm Loan Type S
  • Online Photo Editor – Free Photoediting Software
  • A Guide to Finding the Best Paper Sellers
  • Photoediting in Home Isn’t Hard to Do!

  • Free Photo Editor Online
Categories
  • CSharp (45)
  • Facebook Graph API (19)
  • Google API (7)
  • Internet (87)
  • iPhone XCode (8)
  • Javascript (35)
  • Linux (27)
  • MySQL (16)
  • PHP (84)
  • Problem Issue Error (29)
  • Resources (32)
  • SQL Server (25)
  • Timeline (5)
  • Tips And Tricks (141)
  • Uncategorized (647)
Recommended
  • Custom Software Development Company
  • Online Useful Tools
  • Premium Themes
  • VPS
2014 © 4 Rapid Development