That is a really messy upload code andd you shoudl rethink its structure.
This alone will fail every time
...
} elseif ( $avatar_type == "upload" ) {
if ( $_FILES['avatar_upload']['type'] != "image/gif" ) {
$errors[] = "Avatar must be a GIF or a JPG file.";
}
} elseif ( $avatar_type == "upload" ) {
if ( $_FILES['avatar_upload']['type'] != "image/jpg" ) {
$errors[] = "Avatar must be a GIF or a JPG file.";
}
...
Ok.. What happens when you try to upload? That will always give you an error because first you check if its a gif file and if its not, it gives you an error. Then you check if its a jpg file and if its not, error. So either way you are screwed.
Try somehing like:
if ( $_FILES['avatar_upload']['type'] != "image/gif" || $_FILES['avatar_upload']['type'] != "image/jpg") {
$errors[] = "Avatar must be a GIF or a JPG file.";
}
There are other that kind of bugs in there so check your if clauses carefully. Also use move_uploaded_file() instead of copy()