Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1290 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

MIME types

Thread title: MIME types
Closed Thread    
    Thread tools Search this thread Display Modes  
10-10-2005, 05:43 PM
#1
ktsirig is offline ktsirig
Status: Junior Member
Join date: Oct 2005
Location:
Expertise:
Software:
 
Posts: 46
iTrader: 0 / 0%
 

ktsirig is on a distinguished road

  Old  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!

10-10-2005, 05:48 PM
#2
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

You should really be checking the mime type of the file itself (on the server, in the temporary directory is usually good) rather than relying on the MIME information send from the browser which is easy to fake.

Try playing around with mime_content_type().

The MIME type of plain text files is quite simply text/plain as you already know. Some browsers will (wrongly) send through the application/octet-stream if they're too lazy to send the right type.

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed