In order to Change Permissions Mode (chmod) on the file, you need to own the file first. All the scripts on the web server are running as a "nobody" user, so when you issue the chmod() via php, an error is thrown that a chmod() function is not permitted. To fix this problem try to chmod files / folders that your PHP script access to 777 permissions by the FTP client. If it does not help, please run "Fix File Ownership" tool from your control panel. After the file ownership will be fixed, you will need to chmod these files/folders to 777 immediately, otherwise you will get problems again.