<b>safe_mode</b> is your problem. It is probably imposed by your ISP and you probably don't have control over it.
In safe mode, PHP checks to see if the owner of the script is the same as the owner of the files or directories you trying to delete.
Say it out loud, together:
"PHP checks to see if the <i>owner of the script</i> is the same as the <i>owner of the files or directories</i> you are trying to delete."
When your script uploads the files, the owner becomes the UID of the web server, probably "NOBODY". The owner of the script, however; is probably your user account. Check this by doing a <b>ps -ax</b> in the script directory.
Change the script owner to the same UID as the owner of the uploaded files and you should be fine.
For more info on <b>safe_mode</b> operation and configuration; RTFM ;-) at:
http://www.php.net/manual/en/features.safe-mode.php
-- Rich Rijnders
-- Irvine, CA US