Hi,
You can't, by default, chmod a file from php. There are a lot of permission problem.
In window don't exist chmod. You have to setup this from apache config.
I don't know this too well, but i use on localhost this:
<Directory "e:/testphp">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Write it in httpd.conf of apache. This tell that all is allow in "e:/testphp" directory...