Cevaplar
-
// uzantisi jpg olan dosyalari dizi olarak donderir
$silinecek_dosyalar = glob("*·jpp");
foreach ( $silinecek_dosyalar as $dosya)
{
unlink($dosya);
}// şeklinde daha kisa bir yoldan yaparsin-
hkor
sağol üstad evet daha sade bir kodlama olmuş..12 yıl önce yazılmış
-
-
silme değilde istediği uzantıyı listelemek isteyenlere ekstra kod denendi :
<head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1254"> <title>Egonomik.com :: PHP - Klasör içinde istenen uzantıdaki dosyaları listelemek</title> <style type="text/css"> body { font-family: Arial; font-size: 12px; } .title { background:#4A4A4A; padding: 4px; font-size: 13px; color: #FFFFFF; } .satir1 { background: #F2F2F2; padding: 4px; font-family: Arial; font-size: 11px; } .satir2 { background: #F8F8F8; padding: 4px; font-family: Arial; font-size: 11px; } </style> </head> <body> <?php $dizin = "./ajaxupload"; $uzanti = "jpg"; //hangi uzantı? //Uzantı alma fonksiyonu function ext($text) { $text = strtolower(pathinfo($text, PATHINFO_EXTENSION)); return $text; } echo '<div class="title"><b>'.$uzanti.'</b> uzantılı dosyalar:</div>'; if ($handle = opendir("$dizin") or die ("Dizin acilamadi!")) { $css=0; while (false !== ($file = readdir($handle))) { $filetype = ext($file); if(is_file($dizin."/".$file) && $filetype == "$uzanti") { //eger bir dosya ise ve bizim belirlediğimiz uzantıya sahipse $class = ($css % 2) ? "satir1" : "satir2"; // her satira farklı class echo ' <div class="'.$class.'"><a href="'.$dizin.'/'.$file.'">'.$file.'</a> </div>'; $css++; } } //while end closedir($handle); } ?> </body>