04-09-2008, 06:59 PM
|
#2 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
It looks like the file information is stored in an associative array (but that's not particularly important here). To get at the file names you can use the file_name key on each of the main array items.
For example:
PHP Code:
$bad_file_found = FALSE;
$blacklist = array('php', 'exe');
$blacklist_regex = '/\.(?:'
. implode('|', array_map('preg_quote', $blacklist))
. ')$/iD';
foreach ($zip->getList() as $file)
{
if (preg_match($blacklist_regex, $file['file_name']))
{
$bad_file_found = TRUE;
break; // no need to continue foreach
}
}
if ($bad_file_found)
{
die('Hey, please do not include invalid file types in your ZIP.');
}
die('No invalid files found, woohoo!');
|
|
|
|