chdir('upload'); if ($gestor = opendir('.')) { while (false !== ($entrada = readdir($gestor))) { if ($entrada != "." && $entrada != "..") { $info= pathinfo($entrada); if ($info['extension']=="jpg" || $info['extension']=="png"){ echo '<img width="50" height="50" src="upload/'.$entrada.'">'; } } } closedir($gestor); }