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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking file types

Status
Not open for further replies.

DeepBlerg

Technical User
Jan 13, 2001
224
AU
Hi,

I have a form whereby the user can upload either a Word DOC or an Acrobat PDF.

I am doing a check based on the $_FILES[]['type'] value for either 'application/msword' or 'application/pdf'.

However I have noticed during my Googling that Word files are also referred to as 'application/x-msword-doc', 'application/vnd.ms-word' and so forth.

Will I have to check for all these different variants or is the $_FILES[]['type'] value specific to my server so no matter what browser someone uses I can always check for 'application/msword'?
 
You could use strstr() to find just "word". However, I suggest storing all variable types that you want to allow in an array, and then use in_array().

Code:
If (in_array($_FILES[...]['type'], $fileTypeArray)) {
    ...
}

*cLFlaVA
----------------------------
[tt]insert funny quotation here.[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top