例如,使用php扫描/ favor目录以获取此文件夹内未知文件的名称和类型。
You could make use of finfo_file()
in PHP.
<?php
$finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension
foreach (glob("*") as $filename) {
echo finfo_file($finfo, $filename) . "\n";
}
finfo_close($finfo);
?>
OUTPUT:
text/html
image/gif
application/vnd.ms-excel
Try this it'll get the file name and extensions
$files=glob("files/*"); // files is directory name and * mean all types of files
foreach ($files as $file) {
echo $file."<br />";
}
It'll return file name and format!!!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.