Your httpd server (probably Apache) should be
running as user nobody, group nogroup (or something simular).
This account doesn't have many permissions. It should be able to read the files with your php scripts, but not be able to write to the directories containing those scripts.
That seems to be exactly what is happening, and it's a good thing.
Instead, create a directory for the uploads to go to, change the permissions so it is owned by the same user:group as the httpd deamon runs as (check the configuration files for your httpd), or simply use the /tmp directory.
By the way, you probably want to take more care in how you treat the filename, because that is esentually user-input. It could include semi-colons and pipes and other nasty tricks aimed at getting your system to do something dumb. Picking your own filename is a good idea. If you really want to keep their filename, you should do more work making sure it is harmless.