array_intersect
takes an array as it first parameters. pathinfo($base, PATHINFO_EXTENSION);
gives a String, not an Array.
You can try in_array
:
if (in_array($extension, $allowed_ext)) {
....
}
Also, your $allowed_ext
should be without dots:
$allowed_ext = array("doc", "docx", "pdf", "zip", "jpeg", "jpg", "txt");
because pathinfo($base, PATHINFO_EXTENSION);
gives the extension without the dot.