How to list files in a directory with PHP
Here’s a simple way to execute the windows dir or the linux ls in PHP Windows: <?php $row = exec('dir',$output,$error); while(list(,$row) = each($output)){ echo $row, "<BR>n"; } if($error){ echo "Error : $error<BR>n"; exit; } ?> Linux: <?php $row = exec('ls -ls',$output,$error); while(list(,$row) = each($output)){ echo $row, "<BR>n"; } if($error){ echo "Error : $error<BR>n"; exit; } […]
From our sponsor: Elevate all your marketing with Mailchimp Smarts.
Here’s a simple way to execute the windows dir or the linux ls in PHP
Windows:
<?php
$row = exec('dir',$output,$error);
while(list(,$row) = each($output)){
echo $row, "<BR>n";
}
if($error){
echo "Error : $error<BR>n";
exit;
}
?>
Linux:
<?php
$row = exec('ls -ls',$output,$error);
while(list(,$row) = each($output)){
echo $row, "<BR>n";
}
if($error){
echo "Error : $error<BR>n";
exit;
}
?>
Tagged with: command exec PHP
CSS Reference
Learn about all important CSS properties from the basics with our extensive and easy-to-read CSS Reference.
It doesn't matter if you are a beginner or intermediate, start learning CSS now.
Pingback: PHP: How to list files of a directory
Alem de executar em diretórios ele também server para executar comandos CMD, valeu pelo código obrigado!