Hi,
I Have the following script that lists files in a directory and enables to delete. The script deletes the files but is throwing a continuous error.
The error is:
Warning: unlink(../galleries/gallery1/images/add-to-basket.gif): No such file or directory in c:\inetpub\wwwroot\nicephotos\npadmin\editgallery1.php on line 120
NOTE - The error is on the 9th line.
The Script is:
<?php
$directory = '../galleries/gallery1/images'; // Do not include trailing /
$select_image = $_POST['select_image'];
// If the $select_image array exists, delete each file in it
if (is_array($select_image)) {
foreach ($select_image as $val) {
if (get_magic_quotes_gpc()) { $val = stripslashes($val); }
unlink("$directory/$val");
}
}
// Print a form
echo '<form method="post">';
// Open the directory
$dh = opendir($directory);
if ($dh) {
$x = 0;
// Read each file
while (($file = readdir($dh)) !== FALSE) {
// Skip any directory
if (!is_file("$directory/$file")) continue;
$file = htmlspecialchars($file);
// Print checkbox using name select_image[]
echo '<label for="img' . $x . '">
<input type="checkbox" name="select_image[]" id="img' . $x . '" value="' . $file . '"> ' . $file . '
</label>
<br />';
$x++;
}
closedir($dh);
} else {
echo "Error opening directory.";
}
echo '<input type="submit" value="Delete Selected">';
echo '</form>';
?>
Hope someone can help with this.
Thanks