Search code examples
phpunlink

File exists but will not UNLINK (PHP)


I am trying to check if a file exists and if so delete it. For some strange reason, checking the file returns true but it won't unlink for the life of me. Here is the code I have.

if(file_exists(TEMPLATEPATH.'/uploads/'.$_POST['image_name'])) {
        if (@unlink(TEMPLATEPATH.'/uploads/'.$_POST['image_name'])) {
            echo "true";
        } else {
            echo "false";   
        }
    } else {
        echo "false";   
    }

*note --- without @ there is no errors... *note2 --- this is on localhost windows w/wamp stack and before you say that's why it doesn't work, i confirmed that another site using same syntax works for them without any special permissions.

Thanks for the help!


Solution

  • Ok I am a dumbass and found out that the posted variable name has changed and should have been 'image' instead of 'image_name'....

    Sorry for wasting you guys' time!