Jump to content

PHP Search function and unlink = prevent from deleting this file


Gamerz

Recommended Posts

Hi, I just made a quick code and tested it and it worked...

What I'm trying to do is that I want to type a file via a form in the browser, and then delete the typed file using unlink...(only works if file exists)

 

But I want to prevent from itself being deleted...itself as the form and the delete.php as shown below..

 

Here's the form:

<form action="delete.php" method="post">
<input type="text" name="delete">
<input type="submit">
</form>

 

Here's the unlink code (delete.php)

<?php
$delete = $_POST["delete"];
unlink($delete) or die('Unable to delete the file');
?>

 

So how do i do that?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.