How to List Files in a Directory in PHP
Lấy tất cả các folder có chứa trong thư mục
$arrFiles = array();
$handle = opendir('./path'); Cùng cấp(.)
$handle = opendir('../path'); Trong Admin (..)
if ($handle) {
while (($entry = readdir($handle)) !== FALSE) {
$arrFiles[] = $entry;
}
}
closedir($handle);
#*******************************#
Tìm kiếm tất cả các file có chứa đuôi .txt
trong trường hợp này, $arrFiles chỉ chứa tên .txt tập tin
$arrFiles = glob('/đường dẫn/đến/dir/*.txt');
Link: https://code.tutsplus.com/how-to-list-files-in-a-directory-in-php--cms-38044t

Không có nhận xét nào:
Đăng nhận xét