troubleshooting Question

PHP: Detect if uploaded file is text based

Avatar of headzoo
headzoo asked on
4 Comments1 Solution617 ViewsLast Modified:
  I'm wondering if there are already some functions or classes available to return whether a file (most likely uploaded) is text based or not.  I can probably roll my own, but if something is out there already I'll use that.
  Something like:

$textBased = is_text($fileName);

  The MIME type returned when uploading files isn't very good for this.  For example, uploading a PHP script the MIME type is "application/octet-stream", but we know a PHP script is just plain text.
  Again, I could make my own, and I don't really want anyone going through the trouble of making something just to answer my question.  Just wondering if there is already something available that can do that.

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros