指定したディレクトリ内のすべての画像を表示しようとしています。
次のコードは、許可されているすべてのファイル名を示しています。
function getDirectoryList()
{
// create an array to hold directory list
$results = array();
// create a handler for the directory
$handler = opendir($this->currentDIR);
// open directory and walk through the filenames
while ($file = readdir($handler)) {
// Make sure we get allowed images types
if ($this->allowedFileType($file,$this->allowedImageTypes) )
{
$results[] = $file;
}
}
// tidy up: close the handler
closedir($handler);
// done!
return $results;
}
(...)
$images = getDirectoryList();
foreach($images as $img) {
echo "<li>".$img."</li>";
}
ファイルサイズとMIMEタイプを取得するにはどうすればよいですか?非推奨であると読みました。代わりにfinfo_filemime_content_type
を使用する必要があります。しかし、私はこれであまり成功していません。
/usr/share/misc/magic
ファイル情報を取得するために使用する必要がありますか?GDライブラリを使用できませんか?
私は多くの例を見てきましたが、それらは古く、うまく機能しません。
助けていただければ幸いです。