Jump to content

unlink


JREAM

Recommended Posts

in the first TD on the print part, how would i make the option to unlink the file? do i need to create a function?

if so, how do i get the right filename inside the while loop for the function?

 

while ($file = readdir($dir_handle)) {

if ($file != '.' && $file != '..') {

 

print '<tr>

<td><a href="?action=delete">Delete</a></td>

<td class="shade2"><strong><a href="../../../images/'.$file.'" target="_blank">'.$file.'</strong></td>

<td class="shade2"><input size="40" type="text" value="../../../images/'.$file.'"></td>

</tr>

';

}

}

 

Link to comment
https://forums.phpfreaks.com/topic/123092-unlink/
Share on other sites

<?php
if(isset($_GET['action']) and $_GET['action'] == 'delete'){
     $file = $_GET['file'];
     if(file_exists($file)){
          unlink($file);
     } else{
          echo "File doesn't exist.";
     }
}

while ($file = readdir($dir_handle)) {
     if($file != '.' && $file != '..') {
     print '<tr>
           <td><a href="?action=delete&file='. $file . '">Delete[/url]</td>
           <td class="shade2"><strong><a href="../../../images/'.$file.'" target="_blank">'.$file.'</strong></td>
           <td class="shade2"><input size="40" type="text" value="../../../images/'.$file.'"></td>
           </tr>         
           ';
     }
}
?>

Link to comment
https://forums.phpfreaks.com/topic/123092-unlink/#findComment-635707
Share on other sites

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.