I create file or folder in my PHP script using permission masks 0777: mkdir($dir, 0777); // or chmod($filename, 0777); PHP: Actually it means that these files are accessible/deleteable by everybody. But when I try to delete them through FTP - I can't! I have wasted 2 days trying to fix it... Who can explain it?!
Can you post the permissions of the problems files, as they appear through FTP? Check the owner of the files too, as they'll probably be owned by 'nobody' rather than you. Oh, and also look at the owner and permissions of the parent directory that they are stored in. Cryo.
Cryogenius makes a good point. The server probably is running apache, which would use apache/nobody/www as the user unless SuEXEC is enabled (usually not). PHP has a chown function for changing the ownership of the file to you (as opposed to the web user, which only needs read/exec privileges), and if you still have trouble you could use php to remove the files and reupload using your ftp user.
Yes, I know about chown, but to change it I need to know ftp user name? Seems like yes. OK, thanks to everyone!