/ Published in: PHP

scandir function with more information about the files and folers like the size and mime type
Expand |
Embed | Plain Text
function scandirectorty($directory){ $i = 0; foreach($directorys as $key => $value){ $file[$i]['path'] = $value;// path $open = finfo_open(FILEINFO_MIME_TYPE);// open the mime type of the file }else{ $open = finfo_open(FILEINFO_MIME); // open the mime type } $file[$i]['mime_type'] = finfo_file($open,$value);// get the mime type finfo_close($open); // close the finfo $file[$i]['mime_type'] = mime_content_type($value); // get the mime type } } $file[$i]['dir'] = scand($value.'/');// scan the folder } $i++; } return $file; }else{ trigger_error('Folder <strong>"'.$folder.'"</strong> Not exists',E_WARNING);// show an error if folder not exists } }
You need to login to post a comment.