The issue isn't file type, it's the path.
The values returned by readdir() are file names, not paths...
so when you pass a value from $dirArray to filetype and filesize, you're passing just the name of the file. If there happens to be a file in the current directory with the same name, the...