-
Modify this code.
Right now I have code that allows me to submit text in order to create a .htm file on my server automatically.
I wish to also be able to delete a certain file from the server.
Here is the code I have now that allows me to create files on my server:
Code:
Form:
<form method="post" action="activate.php">
<input name="textarea" type="text" value="">
<input value="Submit" type="submit">
</form>
Activate.php:
<?php
$textarea = $_POST['textarea'];
$textarea = str_replace("\r", "", $textarea);
$textarea = str_replace("\n", "", $textarea);
$textarea = str_replace("\r\n", "", $textarea);
$textarea = str_replace("\n\r", "", $textarea);
$textarea = trim($textarea);
$textarea = str_replace(" ", "_", $textarea);
$file = fopen($textarea . ".htm", "x");
fwrite($file, "authorized");
fclose($file);
chmod($textarea . ".htm", 0777);
?>
I would like code that allows me to delete the file i specify from the server. (permissions are set to do this)
For example, If i added another form to the page, istead of creating the file, delete it.
<form method="post" action="activate.php">
<input name="textarea" type="text" value="DELETETHISFILE.HTM">
<input value="Submit" type="submit">
</form>
Submitting the above form would delete "DELETETHISFILE.HTM" off the server.
Please, thanks.
-
Re: Modify this code.
-
Re: Modify this code.
-
Re: Modify this code.
your code would look something like this:
PHP Code:
$page = "files/html_doc.html";
unlink($page);
you might want to do some error catching too
-
Re: Modify this code.
Anyone want to code it for this lazy SOB? :p
Well not lazy, busy.
-
Re: Modify this code.