When uploading a image over 1.9 MB or so on http://www.dreamuploader.com/ the upload fails and it gives me "wrong filetype". Code edited out
Do never trust the MIME type given in ['type']. This value is defined by the user's browser, and therefore it can be modified/faked. You're not checking for the extension, so what if I sent a PHP file with a fake MIME type to your script? I could do pretty much everything from there on. Plus, some browsers (specially when IE is involved) send a different MIME type, even if the same file is uploaded. Check for the extension, or even use getimagesize() to verify if it's an image. No one will be able to run PHP code with an image extension.