![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Oct 2005
Posts: 54
Rep Power: 4
![]() |
MIMe types
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! |
|
|
|
|
|
#2 |
|
Professional Programmer
|
I don't think PHP checks the MIME types, apache does. If you add something into a .htaccess file giving different file types to be treated as text files it may work, but then again, it would only work with the certain extentions you specify.
|
|
|
|
|
|
#3 |
|
Programming Guru
![]() |
ktsirig, all that is doing is checking the extension... a MIME type via PHP is simply derived from a file extension, nothing more...
You could check for non-printable characters in the file that aren't \n \r \t \0, etc..
__________________
|
|
|
|
|
|
#4 |
|
Programmer
Join Date: Oct 2005
Posts: 54
Rep Power: 4
![]() |
Thanx guys!
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|