Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $cmd = ((isset($_GET['cmd']))? $_GET['cmd'] : '');
- if( $cmd == 'delete'){
- $file = urldecode($_GET['file']);
- if( unlink($file) ){
- $message = '<h3>File: "' . $file . '" has been removed.</h3>';
- }else{
- $message = '<h3>File Deletion Error. Couldn\'t remove file "' . $file . '"</h3>';
- }
- }else{
- $message = '';
- }
- // Get Files in Directory. Obviously you would list your files separately. This being for demo only
- $dh = opendir('.');
- $filesHTML = '';
- while($file = readdir($dh)){
- if( !is_dir($file)){
- $filesHTML .= '<li>' . $file . ' <span style="font-size: 80%;"><input type="button" onclick="window.location=\'?cmd=delete&file=' . urlencode($file) . '\';" value="Delete"></li>';
- }
- }
- ?><!DOCTYPE html>
- <html>
- <head>
- <title>Simple File Deletion</title>
- </head>
- <body>
- <?php echo $message; ?>
- <p>Please Select A File For Deletion:
- <ul>
- <?php echo $filesHTML; ?>
- </ul>
- </p>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement