显示文件夹中的图像并删除图像


Display images from folder and delete images

我有这个脚本来自 http://lampload.com/component/option,com_jdownloads/Itemid,382/cid,69/task,view.download/(我没有使用数据库)我可以上传图像,我可以查看文件,但我想删除它们。当我按下删除按钮时,没有任何反应

http://www.jayg.co.uk/gallery6/upload_gallery.php

<?php
$dir = dirname(__FILENAME__)."/images/gallery" ;
$files1 = scandir($dir);
foreach($files1 as $file){
if(strlen($file) >=3){
$foil = strstr($file, 'jpg'); // As of PHP 5.3.0
$foil = $file;
$pos = strpos($file, 'css');
if ($foil==true){
echo '<input type="checkbox" name="filenames[]" value="'.$foil.'" />';
echo "<img width='130' height='38' src='images/gallery/$file' /><br/>"; // for live host
//echo "<img width='130' height='38' src='/ABOOK/SORTING/gallery-dynamic/images/gallery/      $file' /><br/>";
}
}
}?>
<input type="submit" name="mysubmit2" value="Delete">
</form>

有什么想法吗?

哇!,你的做法是错误的。为了简单起见,为什么不实现数据库在编码中。无论如何,根据您的要求,我已经开发了此代码以及css文件。它已经过测试,现在可以工作了。请评价我的回复,如果您需要进一步的帮助,请给我喊一声。....帕斯托纳

index.php
<?php
extract($_REQUEST);
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<style>

#box{ width:200px; height:auto; border:solid #999 10px; padding:10px; margin:0 auto; margin-top:100px; background-color:#FFF;-webkit-box-shadow: 0 1px 2px #666;box-shadow: 0 1px 2px #666; color:#66F;}
.link{padding:5px; text-decoration:none; background-color:#333; color:#FFF}
</style>
</head>
<body>

<div id="box">

<img src="images/3.jpg" />
<p></p>
<a href="delete.php?del=1" class="link">Delete</a>
</div>

</body>
</html>

delete.php
<?php
extract($_REQUEST);

unlink("images/3.jpg");
// Redirect to a page that prints image deleted successfully
header("Location:success_delete.php");
?>