Notice the "." and the ".." those are directories in which you may not wish to show that represent the current directory and the parent directory respectively. To get redi of the dot and the dotdot, simply check for them like in the following code example:
<?php
//get the lastest file uploaded in uploads/
$path = "uploads";
$d = dir($path);
while (false !== ($entry = $d->read())) {
$filepath = "{$path}/{$entry}";
//Check whether the entry is a file etc.:
$latest_filename = $entry;
if($latest_filename != "." && $latest_filename != "..") {
$latest_filename = $entry;
$file_type = filetype($filepath);//get file type.
$file_size = filesize($filepath);//get file size.
echo "$latest_filename<br />Type: $file_type<br />Size: $file_size<hr />";
}//end if is file etc.
}//end while going over files in excel_uploads dir.
?>
0 comments:
Post a Comment