Permissions
It is important to remember a few key things when working with PHP and file creation. PHP runs via your webserver and therefore has the same rights as your webserver. Since most webservers do not run with super-user status (root in Unix/Linux, or administrator in Windows) you will need to make sure the folders and files you want to edit allow the webserver write access.
Got that all set? If you already know what you are doing with permissions, you can skip to the next section.
If you are running Unix or Linux with Apache you will need to change the owner of your files to ?nobody? or ?www? depending on your install. If you don?t know what user simply type:
ps -aux | grep httpd
This will show you the apache processes running on your server, look to see the name of the user running the process. Now you need to change the permissions of your files.