一切正常,但else
语句不会运行。
<?php
$localhost = "http://localhost";
/* $target_dir = $_SERVER['DOCUMENT_ROOT'].'/uploadmod/uploads/';
*/
$target_dir = "uploads/";
if ($handle = opendir("$target_dir")) {
while (false !== ($file_name = readdir($handle))) {
if ($file_name != "." && $file_name != "..") {
preg_replace('/\\.[^.\\s]{3,4}$/', '', $file_name);
if (file_exists($target_dir.$file_name)) {
echo "<img src=$target_dir". $file_name. ' ' . 'width=25%' . ' ' . 'height='."><br />";
echo "<a href=$localhost/uploadmod/image.php?cmd=viewimage&file_name=$file_name".">View this image</a><br />";
echo "<a href=$localhost/uploadmod/delete_image.php?cmd=delete&file_name=$file_name".">delete</a><br /><br />";
} else {
echo "no image found";
}
}
}
closedir($handle);
}
?>