Jump to content

How to make this ignore certian files


DaHax

Recommended Posts

I am working on a little project for my site and I am trying to get this script to ignore the index.html file and the .htaccess file in there. I just want it to display all files like .zip, .rar, .tar, .gz, .gtar, .ace, ect...

 

		echo "    <td width='70%'><select id='download'>";
        echo "    <option value=''>None</option>";
	if ($handle = opendir("./modules/Downloads/files")) { 
    while (false !== ($file = readdir($handle))) {  
        if ($file != "." && $file != "..") {  
	echo "    <option value='".$file."'>".$file."</option>";  
        }  
    } 
    closedir($handle);  
}


	echo "    </td>\n";

Link to comment
https://forums.phpfreaks.com/topic/211087-how-to-make-this-ignore-certian-files/
Share on other sites

Change this line

if ($file != "." && $file != "..") {  

 

to

if (!in_array($file, $filesToIgnore)) {

 

Now before the while() loop define an array of files you want your script to ignore

$filesToIgnore = array('.', '..', '.htaccess', 'index.html');

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.