No idea how to...

Discussion in 'PHP' started by Lipgut, Jan 9, 2010.

  1. #1
    Problem Solved. Thank you CoreyPeerFly!
     
    Last edited: Jan 9, 2010
    Lipgut, Jan 9, 2010 IP
  2. CoreyPeerFly

    CoreyPeerFly Notable Member Affiliate Manager

    Messages:
    394
    Likes Received:
    24
    Best Answers:
    5
    Trophy Points:
    240
    #2
    Are you looking for something like:
    <form action="" method="POST">
    <table>
    	<th><input name="file" type="text" /></th>
    	<td><input name="submit" type="submit" /></td>
    </table>
    </form>
    <?php
    	if($_POST)
    	{
    		$myFile = $_POST['file'];
    		if(file_exists($_POST['file']))
    		{
    			$handle = fopen($myFile, 'w') or die("Failed to open file.");
    			unlink($myFile);
    			fclose($handle);
    			echo "File Deleted.";
    		} else {
    			die("That file does not exist.");
    		}
    	}
    ?>
    PHP:
    Or are you wanting a delete button next to the file name on the page that lists all of the files?
     
    CoreyPeerFly, Jan 9, 2010 IP
    Lipgut likes this.
  3. Lipgut

    Lipgut Member

    Messages:
    328
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    35
    #3

    Thank you so much! This worked like a charm! Which kinda puzzles me because I also tried using $_post function, must have made an error :S Thank you again!
     
    Lipgut, Jan 9, 2010 IP