When I tried to upgrade my wordpress installation to version 3.4.1, I got following error message.

Downloading update from http://wordpress.org/wordpress-3.4.1-partial-0.zip…

Unpacking the update…

Warning: Invalid argument supplied for foreach() in /some/where/wp-admin/includes/class-wp-filesystem-ftpsockets.php on line 303
Could not copy file.: /some/where/wp-content/upgrade/wordpress-3.tmp/wordpress/wp-admin/includes/update-core.php

Installation Failed

It was a file permission problem. I could fix it by doing following command.

sudo chmod -R daemon /some/where/