Ive been experimenting with the upload capability of php, I have been looking at this tutorial on w3school.
http://www.w3schools.com/php/php_file_upload.asp
I would say the problem is in that If, a lot of conditions there (also "invalid file" is the Else part of that if), try to simplify it to track the problem, at first glance I would say it's because of the size checking:
&& ($_FILES["file"]["size"] < 20000)
that's around 20Kb, quite small for an image if you are uploading a photo, try to put a higher value or to take out that condition and see if the script works