Well, the problem is that when php creates the folders, the folders really don't have an owner. So what you need is to as root go in and delete the folder & files, and then use an FTP function in PHP to create the folders so that you can write to them.
I ran into this problem a while ago. If you search hard enough (you can even go back through my posts) and you'll see a function I used to do FTP to my web-server via PHP.
~Brett
EDIT:
Well, I can't seem to find it, but I have been in discussion about how to delete the files/folders. I still think you need to be root to delete them. Anyway, here's a quick & dirty way to create folders:
<?php
function createDir($path)
{
$host = 'ftp.host.com';
$user = 'ftp_username';
$pass = 'ftp_password';
$con_id = ftp_connect($host);
$fcon = ftp_login($con_id, $user, $pass);
if(!$con_id || !$fcon)
{
die('Error connecting to FTP Server!!');
}
else
{
if(!@ftp_mkdir($path))
{
die('Error creating directory!!');
}
else
{
echo 'Directory successfully created!!';
}
}
}
?>
You can read more about it here
~Brett