i have a script that creates a temp file that needs to be deleted when the script finishes.
the file path(including file name) is in a variable $tempfilepath
for UNIX systems, I have:

@$mod= chmod($tempfilepath, 0646);
if (!$mod)
{
echo "Couldn't modify temp file permissions!";
die();
}
@$unlink= unlink($tempfilepath);
if (!$unlink)
{
@$unlink= system("del $tempfilepath ");
if (!$unlink)
{
echo "<br>Couldn't delete file<br>";
}
}

then where it deletes, if there is an error using the unlink() function, i revert to the system() command,
i just tried it on my computer and it returns my error: "couldn't delete file"

so how do I go about deleting files correctly both on UNIX and in Windows(2000 or XP)

    the system()-call hasn't other rights than unlink()
    if that doesn't work, you can't delete the file

    note, that any php-script is executed by another user with
    other permissions than your ftp-user you use when uploading

    anyway, Win: del <file>
    Unix/Linux: rm <file>

      i'm trying to chmod a directory to 777, but it says operation not permitted, anyway to fix this?

        if your not the owner of the server, i guess your out of luck. Otherwise you need to set the properties of the dir on the server.

          Write a Reply...