Disclaimer: This may sound the wrong way, but I don't intend to insult you
But NEVER EVER EVER put a file 777.
In order for files to be uploaded, the DIRECTORY needs to be read/writeable by the webserver user only.
You can control the types of files that are uploaded by your php, using the meta tags of your images. Check php.net/_FILES for more info.
This prevents losers who pick their butts from putting files up and trying to hack your server.