I am a novice php programmer and need a bit of help from a server admin to understand a few points where I am totally lost.

1)When I create a php script, how do I find out which user is running the script? I am using the OS: CENTOS 6.7 x86_64 standard

2)I cannot upload a single image in my folders if the folders are not chmod777, how can I stop this please?

3)I only have 1 single account on my dedicated server, how can I let the script run using this user to remove any chmod problems please?

If you could send me a few commands it would be fantastic!
I am just trying to make my server a bit more secure by eliminating any folders which have chmod777.