Know about file location
1. We are on 'C:\xampp\htdocs\letdelete\index.php
In letdelete
directory we have some zipp files ,we want to delete all
the zip files.
v Alice.zip
v Mone.zip
v Cane.zip
index.zip$ar = array();
$ar1 = array();
$directory = "./";
$files = glob($directory ."*");
foreach($files as $file)
{
if (is_dir($file)) {
/* nothing to do*/
}else {
$ar1[] = basename($file);
}
}
$ab=count($ar1);
for($a=0;$a<$ab;$a++)
{
$source=$ar1[$a];
if (strpos($source,'zip') !== false) {
if(file_exists($source))
{
unlink($source);
} } }
My Code is running successfully thanks Gaurav Keep Posting More.
ReplyDelete