the error is happening because of this code which is writting the files array tothe page:
if (($_SERVER["REQUEST_METHOD"] == "POST")) {
var_dump($_FILES);
}
remove that.
The redirect is probably happening because the authenticate user server behavior in the login plugin page is set to trigger on any form post.
edit the authenticate user behavior, and set the trigger to happen on the login button being pressed.