Found where I made the error, on the condition, my code was:
if ($filetype['type'] != $fileCSV || $filetype['type'] != $fileText) {
echo "Error, the file $filename has not a valid extension: " . $filetype["ext"];
continue;
}
And the right is this one:
if (!in_array($filetype['type'], array($fileCSV, $fileText))) {
echo "Error, the file $filename has not a valid mimetype: " . $filetype["type"];
continue;
}