$allowed_ext = array('gif', 'png', 'jpg', 'jpeg'); if (in_array($exts, $allowed_ext)) { //write your code here }