Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3720768
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:19:38+00:00 2026-05-19T05:19:38+00:00

i want my PHPapp to read a file and tell me if it’s a

  • 0

i want my PHPapp to read a file and tell me if it’s a word, excel or powerpoint file. my first approach was to read the extension of the file. But microsoft has different file extension names, and i was also wondering about files uploaded by a mac (with no filename extension)

So, maybe the answer is using mimetypes. Do you know a better approach for this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T05:19:39+00:00Added an answer on May 19, 2026 at 5:19 am

    Yes, trying to determine the MimeType is your best bet short of just try/catching to load the files with PHPWord, PHPExcel and PHPowerpoint directly to see if they throw an exception (Mark Baker correct me please if they dont throw exceptions).

    See my answer to

    • PHP how can i check if a file is mp3 or image file?

    for various ways to detect the MimeType.

    You can find a number of possible MimeTypes for Office documents at

    • http://filext.com/faq/office_mime_types.php and
    • http://social.msdn.microsoft.com/Forums/en-US/exceldev/thread/87b9cd73-a41b-4fd0-94c7-dfe53e92947e
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PowerPoint 2007 slide with two embedded Excel objects. I want to
Want to find one and modify that to read, write file on mongoDB gridfs
want to open pdf file when a user clicks on hyperlink shown in gridview
Want the function to sort the table by HP but if duplicate HPs then
I want a simple thing with Facebook API, but I don't know if it's
The company has a PHP app that is in horrible condition. They want to
I want the Security Component turned on. BUT when you load a CakePHP app
I don't want an other application to read the files while this php app
Want to update page after jeditable (using gem on_the_spot) has been updated. Below works
I have read a lot about the clear cache command for symfony2, but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.