I'm working on a task for a client that I thought would be simple. A remote computer uploads a file upon some event. My site needs to display a flag/statement if that file exists. So, upon page load it checks if the file exists. That all works fine and dandy.
The problem is that the user wants to have a reset button. In other words, after he sees that the flag is set, he wants to be able to click a button or text link and delete that file. I want to use something like this.
<?php
if (file_exists($triggerfile)) {
echo '<input type="button" value="Delete" onClick="'.unlink($triggerfile).'">';
} else {
echo "The file $triggerfile does not need to be reset";
}
?>
Initially I thought that I had this, but now I realize that it's not really working as I had thought. Instead of deleting the file with onclick, it's falling through that code and deleting that file whether someone clicks or not.
Can anyone tell me what I'm doing wrong here or how I can accomplish this simple task?
Thanks in advance for your help!