Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check for more then one MIME 1

Status
Not open for further replies.

maharamDan

IS-IT--Management
Mar 22, 2004
31
US
Hello this might be a simple question.

I have 4 MIME I want to check during an upload script.

Application/PDF
Application/MSWORD
Applicatoin/MSEXCEL
plain/text

How would I incorporate this in one statement.

Should I do an if else type thing?

Right now I have:

if ($userfile_type != "application/msword")
{
echo "Problem: file is not a word document";
exit;
}

Anyway I could put .doc, .pdf , .txt ,.xls in an array or something?

Thanks in advance.
Dan
 
You could.

Create an array in your code that has all the content-types you wish to check for:

$content_types = array ('application/msword', 'application/msexcel'.......);

Then loop through the array, checking to see whether the content-type returned by the browser matches anything in the list:

foreach ($content_types as $content_type)
{
if ($content_type .....)
{
//do something
}
}


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top