Should I take it that you have given 'nobody' full rights and ownership to the FTP folder at the filesystem level???
From personal experience, I'm pretty confident that its a permissions issue (as you say), although I haven't figured out the dynamics of it. For instance, you have the same problem if you try to update Wordpress on localhost (using 'via FTP' option) - you just can't do it, even if you have the right credentials. Its not just on Linux, I have that issue on Windows/Apache as well (which kind of sets aside the Linux filesystem permissions issue). I think the problem is that 'you' (the process) are already 'someone' else on the system, and that someone does not have the right to grant (or maybe I should say 'can't' grant) privileges to another user to use another protocol. I'm thinking of execution privileges, like within Apache. In fact, now that I have typed that - I think that's it its a protocol issue, maybe inside Apache.
A few suggestions -
You also might want to look at the code Wordpress uses for that function, and maybe test it (a quick WP install) and see if it has the same issue (update via FTP on localhost)
Try creating a file - see what happens -
I suggest you try the same code with a second machine set up to be the target. OR try the script as CGI. If either works, it bears out my scenario.