Results 1 to 6 of 6

Thread: Modify this code.

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Posts
    395

    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.

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Modify this code.


  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Posts
    395

    Re: Modify this code.

    wow uh thanks.
    8 gigs/ram (hey why not)
    300 gig HD x2
    Windows XP 64

  4. #4
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    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
    My usual boring signature: Something

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Posts
    395

    Re: Modify this code.

    Anyone want to code it for this lazy SOB?

    Well not lazy, busy.
    Last edited by penagate; Jun 10th, 2007 at 09:33 AM. Reason: merged double post

  6. #6
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Modify this code.

    My usual boring signature: Something

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width