Forum Moderators: coopster

Message Too Old, No Replies

MIME types

text files

         

ktsirig

5:37 pm on Oct 10, 2005 (gmt 0)

10+ Year Member



Hi!
I am trying to validate that a file submitted through a form is a TEXT file.
When I use $_FILES['userfile_PFAM']['type']=='text/plain' it works, but only for files with .txt extension.

But the user may also have a file containing text data and may not have given the .txt extension (for example I found that application/octet-stream also reffers to TEXT files).
Does anybody know which of the MIME types of PHP must I check for? The MIME types that reffer to TEXT I mean.

Thanx!

StupidScript

8:46 pm on Oct 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The basic MIME type for text files is, as you have indicated: text/plain

Many types of files can contain text, yet be of a different MIME type, like application/ms-word, for example ... lots of text, but in a different type of file.

See The Internet Assigned Numbers Authority web site [iana.org] for a pretty complete list of MIME types, then select the ones you think your visitors will be uploading. You may, in fact, want to tell them which types of files you will accept.