Strpos function in php and an array as needle
Frage
I want to check the mime-type of uploaded file in php and return true if it is allowed.
I have an array of some part of allowed mime-types like this:
$allowedMimes = array('images','word','pdf');
images is for jpg/png/gif and word is for doc/docx and pdf for pdf.
the mime-type of an uploaded docx file is for example:
application/vnd.openxmlformats-officedocument.wordprocessingml.document
now i need to check it in array.i think i should use strpos but i don't know how use it with an array.
would you help me?
Lösung
foreach( $allowedMimes as $mime ) {
if( strpos( 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' , $mime ) ) {
return true;
}
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow